Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/watson/console-log-level
The most simple logger imaginable
https://github.com/watson/console-log-level
Last synced: 4 days ago
JSON representation
The most simple logger imaginable
- Host: GitHub
- URL: https://github.com/watson/console-log-level
- Owner: watson
- License: mit
- Created: 2015-01-05T16:12:38.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-03T14:06:30.000Z (about 1 year ago)
- Last Synced: 2024-10-30T01:36:55.122Z (2 months ago)
- Language: JavaScript
- Size: 35.2 KB
- Stars: 111
- Watchers: 9
- Forks: 27
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nodejs-cn - console-log-level - 可以想象的最简单的记录器,支持日志级别和自定义前缀 (包 / 日志)
- awesome-nodejs-cn - console-log-level - **star:111** 最简单的日志程序,支持日志级别和自定义前缀 (包 / 日志)
- awesome-nodejs - console-log-level - The most simple logger imaginable with support for log levels and custom prefixes. (Packages / Logging)
- awesome-nodejs - console-log-level - The most simple logger imaginable - ★ 30 (Logging)
- awesome-node - console-log-level - The most simple logger imaginable with support for log levels and custom prefixes. (Packages / Logging)
- awesome-nodejs-cn - console-log-level - 可以想象的最简单的记录器,支持日志级别和自定义前缀. (目录 / 日志)
README
# console-log-level
A dead simple logger. Will log to STDOUT or STDERR depending on the
chosen log level. It uses `console.info`, `console.warn` and
`console.error` and hence supports the same API.Log levels supported: trace, debug, info, warn, error and fatal.
[![npm](https://img.shields.io/npm/v/console-log-level.svg)](https://www.npmjs.com/package/console-log-level)
[![Build status](https://travis-ci.org/watson/console-log-level.svg?branch=master)](https://travis-ci.org/watson/console-log-level)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)## Installation
```
npm install console-log-level
```## Example usage
```js
var log = require('console-log-level')({ level: 'info' })log.trace('a') // will not do anything
log.debug('b') // will not do anything
log.info('c') // will output 'c\n' on STDOUT
log.warn('d') // will output 'd\n' on STDERR
log.error('e') // will output 'e\n' on STDERR
log.fatal('f') // will output 'f\n' on STDERR
```## Options
Configure the logger by passing an options object:
```js
var log = require('console-log-level')({
prefix: function (level) {
return new Date().toISOString()
},
level: 'info'
})
```### level
A `string` to specify the log level. Defaults to `info`.
### prefix
Specify this option if you want to set a prefix for all log messages.
This must be a `string` or a `function` that returns a string.Will get the level of the currently logged message as the first
argument.### stderr
A `boolean` to log everything to stderr. Defauls to `false`.
## License
[MIT](LICENSE)