Initializes the lognetic client.
lognetic.init({
debug: false,
uri: '//example.com',
paths: {
message: 'api/message',
event: 'api/event',
error: 'api/error'
},
console: {
log: false,
warn: false,
error: true
}
environment: 'prod'
}))
lognetic.init
accepts these properties in the options object.
boolean
value to turn debug mode on or off. If debug is enabled, the SDK will attempt to print out useful
debugging information when sending messages.
Default value is false
.
This object allows you to specify which console actions to record. The default value is
{ log: false, warn: false, error: true }
.
Specifies the value for . This will be a server-side endpoint that will accept our message object.
Specifies the value for the base url that messages are sent to. This will be a server-side endpoint that will accept our message object.
Specifies the HTTP method used to send messages. Acceptable values are POST
, PUT
or PATCH
since our message object is passed as a JSON body.
Default value is POST
.
Specifies the HTTP protocol to use when sending messages. By default, the protocol of the current domain is used.
string
value to specify your release environment, such as staging
, production
or similar.
The paths object allows you to specify separate endpoints for sending Messages, Events and Errors.
Note Paths are relative and is concatenated with the base uri
when sending.
Note If null then all message types (Message, Event, Exception) are sent using the base uri
.
Specifies the relative path that messages are sent to.
Specifies the relative path that events are sent to.
Specifies the relative path that exceptions are sent to.
Sends a error exception.
error (required): a JavaScript Error object
data: additional data to send(must contains values of string, number, or boolean)
lognetic.writeException(error, data);
Sends a custom info-level message.
message (required): the custom message to log
data: additional data to send(must contains values of string, number, or boolean)
lognetic.writeMessage(message, data);
Sends a custom info-level message.
id (required): event id
message (required): the custom message to log
category (option): event category
lognetic.writeEvent(id, message, category);
Adds a breadcrumb data object to trail sent with messages.
data (required): Breadcrumb object
data format { category: string, message: string, timestamp: date|number, data: object }
lognetic.addBreadcrumb(data);
Assigns custom meta data that will be sent along with each exception.
data (required): custom meta data, can be user to store user details
lognetic.setMetaContext(data);
Allows you to set your application version.
version (required): application version as string
lognetic.setAppVersion(version);