Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/titarenko/totlog
The only true log
https://github.com/titarenko/totlog
categories category color colors log logger logging logstash slack
Last synced: 29 days ago
JSON representation
The only true log
- Host: GitHub
- URL: https://github.com/titarenko/totlog
- Owner: titarenko
- Created: 2015-10-26T14:29:56.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-10-17T07:19:11.000Z (3 months ago)
- Last Synced: 2024-11-20T07:44:53.025Z (about 2 months ago)
- Topics: categories, category, color, colors, log, logger, logging, logstash, slack
- Language: JavaScript
- Homepage:
- Size: 95.7 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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.
[![Build Status](https://travis-ci.org/titarenko/totlog.svg?branch=master)](https://travis-ci.org/titarenko/totlog)
[![Coverage Status](https://coveralls.io/repos/github/titarenko/totlog/badge.svg?branch=master)](https://coveralls.io/github/titarenko/totlog?branch=master)## How to use
`mymodule.js`
```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`
```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`
```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
```js
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