0.0.5 • Published 2 years ago

@konso/logging v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Logging

Installation


npm i @konso/logging

Example


import { createClient, LogEvents } from "@konso/logging";

let client = createClient({
  apiURL: 'https://devapis.konso.io',
  bucketId: '1fc41560',
  apiKey: 'REa9xeOvk6fRxAcNEyebk+5nC5LnbeCr+bJTBpoLm5E=',
  appName: 'test'
})

client.on(LogEvents.onSuccessful, (text) => { console.log(text) })
  .on(LogEvents.onError, (text) => console.error(text));

client.log('message', 'error')

createClient

createClient - the function takes a parameters object and returns an instance of the Logging class

const client = createClient({
  apiKey: 'REa9xeOvk6fRxAcNEyebk+5nC5LnbeCr+bJTBpoLm5E=',
  apiURL: 'https://devapis.konso.io',
  bucketId: '1fc41560',
  appName: 'test'
})
ParameterTypeRequired
apiKeystringtrue
apiURLstringtrue
bucketIdstringtrue
machineNamestringfalse
envstringfalse
appNamestringfalse

Methods


on

on(eventName: LogEvents, callback: (text: string) => void);

Parameters

ParameterTypeRequiredValue
eventNamestringtrue'onSuccessful', 'onError' or keys of LogEvent object
callbackfunctiontrue(text: string) => void

log

log(message: MessageTypes, logLevel?: LogLevel | MessageTypes, extraOptions?: ExtraOptions): PromiseLike<void>;

Parameters

ParameterTypeDefaultRequiredValue
messagestring, number, Array, Object, Errortrue
logLevelstring, number, Array, Object, Errorfalse
extraOptionsObjectfalse{ eventId?: string, correlationId?: string }
0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.1

2 years ago