0.1.1 • Published 2 years ago

lognetic-browser v0.1.1

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
2 years ago

Lognetic for Browsers

npm node size

lognetic.init

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'
}))

Options

lognetic.init accepts these properties in the options object.

debug

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.

console

This object allows you to specify which console actions to record. The default value is { log: false, warn: false, error: true }.

appKey

Specifies the value for . This will be a server-side endpoint that will accept our message object.

uri

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.

method

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.

protocol

Specifies the HTTP protocol to use when sending messages. By default, the protocol of the current domain is used.

environment

string value to specify your release environment, such as staging, production or similar.

paths

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.

paths.message

Specifies the relative path that messages are sent to.

paths.event

Specifies the relative path that events are sent to.

paths.error

Specifies the relative path that exceptions are sent to.

lognetic.writeException

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);

lognetic.writeMessage

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);

lognetic.writeEvent

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);

lognetic.addBreadcrumb

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);

lognetic.setMetaContext

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);

lognetic.setAppVersion

Allows you to set your application version. version (required): application version as string

lognetic.setAppVersion(version);

License

BSD 3-Clause

0.1.0

2 years ago

0.1.1

2 years ago

0.0.7

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago