Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/therebelrobot/trace-debug-log
Add traces and environment context to your console.log in Node.js applications
https://github.com/therebelrobot/trace-debug-log
Last synced: 9 days ago
JSON representation
Add traces and environment context to your console.log in Node.js applications
- Host: GitHub
- URL: https://github.com/therebelrobot/trace-debug-log
- Owner: therebelrobot
- Created: 2015-04-17T17:01:42.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-08T18:41:37.000Z (over 9 years ago)
- Last Synced: 2024-05-07T07:01:43.100Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 159 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# trace-debug-log
An environment based mini-lib to replace console.log in Node.js applications. Adds log trace and context information automatically. Without the `DEBUG` environment variable, all logs are silent.
## Install
```sh
npm install --save trace-debug-log
```## Usage
```js
var debug = require('trace-debug-log')debug.enable()
function _namedFunction(param){
debug('This is an example', param)
}_namedFunction('function parameter')
// filename.js:6 in _namedFunction() This is an example function parameter
_namedFunction(42)
// app.js:6 in _namedFunction() This is an example 42
_namedFunction({param:'foo'})
// app.js:6 in _namedFunction() This is an example { param: 'foo' }
```###`debug.enable()`
This is a helper function so you do not need to set the environment variable prior to running your app. If this gets run, `process.env.DEBUG` will be set to true, and all debug logs will be printed to console.
###`debug.disable()`
This is a helper function to unset the debug variable. If this gets run, `process.env.DEBUG` will be set to false, and all debug logs will be ignored.
## LICENSE (ISC)
Copyright (c) 2015, Trent Oswald
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/therebelrobot/trace-debug-log/trend.png)](https://bitdeli.com/free "Bitdeli Badge")