kalayo-logger v1.0.5
Kalayo JS Logger
This function connects to the easy-to-use Kalayo service for use with any JavaScript service. Try it out for free today!
Documentation
Installation
npm install kalayo
or
yarn add kalayo
Usage
Initialization
You'll need to initialize the url where you want the logs to be sent. This should be executed before making any logs. An ideal place to put this would be at the the top level of your application. You only need to do this once.
The Kalayo() function accepts a headers object as an optional second parameter. If you're using Kalayo's dashboard, make sure to pass an Authorization
property with your API token as its value.
import Kalayo from 'kalayo';
new Kalayo('https://localhost:3000', {
'Authorization': `Bearer ${token}`
});
Logging
The actual log functions can be found below.
import { log, d, w, e } from 'kalayo';
log()
log(message, stackTrace, logOptions)
Parameter | Description | Required | Type | Default |
---|---|---|---|---|
message | Text to display for the log. | no | string | null |
stackTrace | Stack trace details | no | object or string | "" |
logOptions | Other info you want to pass to the server. | no | object | default |
d()
Same signature as log
but overrides logOptions.level
to 'default'
.
d(message, stackTrace, logOptions)
w()
Same signature as log
but overrides logOptions.level
to 'warning'
.
w(message, stackTrace, logOptions)
e()
Same signature as log
but overrides logOptions.level
to 'error'
.
e(message, stackTrace, logOptions)
Suggested log options
Property | Type | Values | Default |
---|---|---|---|
logLevel | string | 'default' ,'warning' ,'error' | undefined |
os | string | 'Web' , 'Android' , 'iOS' | undefined |
osVersion | string | '12.0' , '9.1.1 ' | undefined |
deviceType | string | 'iPhone' , 'Google Pixel' | undefined |
deviceVersion | string | 'X' , '3' | undefined |
License
MIT © AMAGI