Logging Service
Logging Service provides the HTTP Interface to write log-messages for a Component.
Pre-requisite¶
In order to use Logging Service APIs:
- The Location Service
- Gateway Server needs to be running in the network
Creation of Logging Service¶
To create Logging Service¶
sourceconst loggingService: LoggingService = await LoggingService()
const locationService: LocationService = await LocationService()
APIs¶
Async-Await
Note that the examples are using async/await which makes handling of promises more readable.
Usages of Logging Service¶
Type Definition for the Logging Service interface can be found here
Creating Log for an incident¶
This method will be used to create a log entry for a component with a specific log Level.
I.e. when a user submits a setup command for a component using Command Service.
User may want to create explicit log entry based on success or failure scenario.
Type definition can be found - here.
sourcelet prefix = new Prefix('ESW', 'comp1')
const commandService: CommandService = await CommandService(new ComponentId(prefix, 'Assembly'))
const intParam = intKey('positions').set([1, 2, 3])
const setup = new Setup(prefix, 'move', [intParam])
const response = await commandService.submit(setup)
switch (response._type) {
case 'Completed':
await loggingService.log(prefix, 'INFO', 'Successfully submitted move command', {
params: [intParam]
})
break
default:
await loggingService.log(prefix, 'ERROR', 'Failed to submit move command', {
params: [intParam]
})
}
0.4.1-RC1