Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gulpjs/fancy-log
Log things, prefixed with a timestamp.
https://github.com/gulpjs/fancy-log
Last synced: 5 days ago
JSON representation
Log things, prefixed with a timestamp.
- Host: GitHub
- URL: https://github.com/gulpjs/fancy-log
- Owner: gulpjs
- License: mit
- Created: 2015-09-07T22:59:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-29T20:11:28.000Z (about 1 year ago)
- Last Synced: 2024-10-29T15:14:42.099Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 121
- Watchers: 7
- Forks: 21
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nodejs - fancy-log - Log things, prefixed with a timestamp. ![](https://img.shields.io/github/stars/gulpjs/fancy-log.svg?style=social&label=Star) (Repository / Logging)
README
# fancy-log
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]
Log things, prefixed with a timestamp.
## Usage
```js
var log = require('fancy-log');log('a message');
// [16:27:02] a messagelog.error('oh no!');
// [16:27:02] oh no!
```## API
### `log(msg...)`
Logs the message as if you called `console.log` but prefixes the output with the
current time in HH:mm:ss format.### `log.error(msg...)`
Logs the message as if you called `console.error` but prefixes the output with the
current time in HH:mm:ss format.### `log.warn(msg...)`
Logs the message as if you called `console.warn` but prefixes the output with the
current time in HH:mm:ss format.### `log.info(msg...)`
Logs the message as if you called `console.info` but prefixes the output with the
current time in HH:mm:ss format.### `log.dir(msg...)`
Logs the message as if you called `console.dir` but prefixes the output with the
current time in HH:mm:ss format.## Styling
If the terminal that you are logging to supports colors, the timestamp will be formatted as though it were a `Date` being formatted by `util.inspect()`. This means that it will be formatted as magenta by default but can be adjusted following node's [Customizing util.inspect colors](https://nodejs.org/dist/latest-v10.x/docs/api/util.html#util_customizing_util_inspect_colors) documentation.
For example, this will cause the logged timestamps (and other dates) to display in red:
```js
var util = require('util');util.inspect.styles.date = 'red';
```## License
MIT
[downloads-image]: https://img.shields.io/npm/dm/fancy-log.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/fancy-log
[npm-image]: https://img.shields.io/npm/v/fancy-log.svg?style=flat-square[ci-url]: https://github.com/gulpjs/fancy-log/actions?query=workflow:dev
[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/fancy-log/dev.yml?branch=master&style=flat-square[coveralls-url]: https://coveralls.io/r/gulpjs/fancy-log
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/fancy-log/master.svg?style=flat-square