@balena/event-log
TypeScript icon, indicating that this package has built-in type declarations

6.8.0 • Public • Published

Balena Event Log

Balena event logging facility.

Installing

$ npm install @balena/event-log

Using

var EventLog = require('@balena/event-log')

var eventLogger = EventLog({
	debug: true,
	prefix: 'UI, CLI, etc.',
	// Hooks:
	beforeCreate: function (type, jsonData, applicationId, deviceId, callback) {
		this.start('User ID', callback)
	}
	afterCreate: function (error, type, jsonData, applicationId, deviceId) {
		if (type === 'User Logout') {
			this.end()
		}
		if (error) {
			console.error(error)
		}
	}
})

// Example logged event:
eventLoger.user.login(
	{ json: 'data' }, // Or null
	'Application ID', // Optional
	'Device ID' // Optional
)

// Example logged event without params:
eventLoger.user.login()

Options

  • prefix - subsystem name like UI or CLI, acts as events names prefix
  • [debug = false] — will print some warnings

Hooks:

beforeCreate = function (type, jsonData, applicationId, deviceId, callback) { return callback() } 
afterCreate = function (error, type, jsonData, applicationId, deviceId) {}

Readme

Keywords

none

Package Sidebar

Install

npm i @balena/event-log

Weekly Downloads

503

Version

6.8.0

License

Apache-2.0

Unpacked Size

27.9 kB

Total Files

7

Last publish

Collaborators

  • dfunckt
  • page
  • balena.io