2.1.1 • Published 7 years ago
totlog v2.1.1
totlog
The only true log: zero dependencies, categories, colors, events for flexible support of additional appending logic. Bonus: slack and logstash appenders. Extra bonus: (almost) everything is tested.
How to use
mymodule.js
const log = require('totlog')(__filename)
log.debug('anything that %s could pass to %s', 'you', 'util.format')
// will output colored content to console with
// - time
// - category = module filename relative to project root folder
// - level
// - formatted message
Advanced
log.js
const log = require('totlog')
module.exports = log
const slack = log.appenders.slack({ token: 'chpoken', channel: 'alerts', icon: ':hideyourpain:' })
log.on('message', message => {
if (message.level == 'error') {
slack(message)
}
})
// notice how easy it is to define custom appending logic
// everything you need is JS knowledge
// without experiencing complex and/or obscure APIs
mymodule.js
const log = require('./log')(__filename)
log.error('anything that %s could pass to %s', 'you', 'util.format')
// message will appear both in console and in slack
Appenders
Slack
const slack = log.appenders.slack({ token, channel, icon })
const logstashTcp = log.appenders.logstash('tcp://host:port')
const logstashUdp = log.appenders.logstash('udp://host:port')
License
MIT
2.1.1
7 years ago
2.0.2
8 years ago
2.0.1
8 years ago
1.0.2
8 years ago
0.2.3
9 years ago
0.2.2
9 years ago
0.2.1
9 years ago
0.2.0
9 years ago
0.1.3
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago
0.0.8
10 years ago
0.0.7
10 years ago
0.0.6
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago