0.2.0 • Published 7 years ago
firebase-winston v0.2.0
firebase-winston
A Firebase transport for Winston
Usage
const winston = require('winston');
const admin = require('firebase-admin');
const FirebaseLogger = require('firebase-winston');
const db = admin.database();
winston.add(FirebaseLogger, { ref: db.ref('logs') });
winston.log('info', 'This is a message', { anything: 'This is metadata' })
Options
Required is that you set the ref option when adding a transport.
Firebase needs a key to store an object. If no key option is set, the current timestamp will be used.
If you do set the key option, all your logs that use the FirebaseLogger have to include a key/value in the metadata with that name.
winston.add(FirebaseLogger, {
ref: db.ref('logging'),
key: 'my_key'
});
winston.log('error', 'Something went wrong', { anything: 'This is metadata', my_key: 123 })