A powerful and customizable logging library for node.js. support color console with timestamp, line number, method name, file name and call stack. you can set transport to file, stream, database(ex: mongodb and clouddb, simpledb). keywords: log, logger, t
var obj = { Request: [ { IsValid: ['True'], ItemSearchRequest: [ { ResponseGroup: ['Small', 'OfferSummary'], Sort: ['salesrank'], SearchIndex: ['DVD'] } ] } ]}var logger = require('tracer').console({ inspectOpt: { showHidden: true, //the object's non-enumerable properties will be shown too depth: null //tells inspect how many times to recurse while formatting the object. This is useful for inspecting large complicated objects. Defaults to 2. To make it recurse indefinitely pass null. }})logger.log(obj)//// 2013-09-30T04:30:44.927Z <log> depth.js:26 (Object.<anonymous>) { Request:// [ { IsValid: [ 'True', [length]: 1 ],// ItemSearchRequest:// [ { ResponseGroup: [ 'Small', 'OfferSummary', [length]: 2 ],// Sort: [ 'salesrank', [length]: 1 ],// SearchIndex: [ 'DVD', [length]: 1 ] },// [length]: 1 ] },// [length]: 1 ] }
Specify the stack index for file info
Fix file, path, and line info width stackIndex.
It is userful for development package.
var logger = require('tracer').console({ stackIndex: 0 // default 0})var logger2 = require('tracer').console({ stackIndex: 1})var logMgr = function(type, msg) { return logger[type](msg)}var logMgr2 = function(type, msg) { return logger2[type](msg)}logger.log('hello') // the line info is rightlogger2.log('hello') // the line info is errorlogMgr('log', 'hello') // the line info is errorlogMgr2('log', 'hello') // the line info is right
setLevel and close
setLevel and close methods to dynamically change the log level.
these are global settings, affect all output that are created via tracer
var tracer = require('tracer')tracer.setLevel(2) //or tracer.setLevel('debug');//... ...tracer.close()
notice:
if you set level in initialize, you can't change more lower level than the initial level.
support count, assert and table methods.
Read examples please. consoleMethods.js
More features, please read examples.
History
1.3.0
Update packages
Enable dailyfile only on nodejs
1.1.6
Merged: Typings for new methods #131 by @zS1L3NT
Merged: Update type of depth property in inspectOpt #134 by @SufianBabri
1.1.5
Updated some packages to the latest version. Fixed severity vulnerability
1.1.4
Fixed fixes security vulnerability by GitHub bot
Merged fix bug then when set allLogFile cannot delete old old files #122. Thanks @horsefaced
Congratulations 1.1K Stargazers
1.1.0
Updated map tracer.warn to console.warn. Thanks @eouia
Fixed webpack warning "Critical dependency: the request of a dependency is an expression". Thanks @tjr
Fixed Move nyc from dependencies to devDependencies. Thanks @madarche
1.0.3
Updated some packages to the latest version. Fixed severity vulnerability
1.0.2
Updated some packages to the latest version
Released
0.9.9
Fixed. Port tests from expresso to mocha. Fixes #105 #106 by @ossdev07.
Fixed. Update type definitions to be able to use array in filters. #104 by @irisked.
Fixed potential security vulnerabilities in your dependencies in istanbul package.
0.9.8
Added. {{folder}} template option for parent folder. #96 by @shbatm.
Added. rootDir param option for folder. #99 by @nswbmw. sample: folder.js and folder2.js
0.9.5
Fixed. Update index.d.ts and dtslint for typescript. #92 and #94 by @Diluka.
0.9.3
Fixed. Any custom keys for typescript. #90 by @Diluka.
Updated formatJson sample
0.9.2
Fixed. Make type definitions correct & add comments. #89 by @plylrnsdy.
Updated npm packages
0.9.1
Fixed. transport function parameter data type is LogOutput not string #87 by @myfjdthink.
0.9.0
Added support all console methods, include count,assert and table. a new option 'supportConsoleMethods' is true default. example: consoleMethods.js in example folder.
0.8.15
Adding type definitions #84 by @kobim
Added data.rawoutput #83 by @Royalgamer06
recommended linting #82 by @elomariAchraf
0.8.12
added the ability to load the config from a file. #80 thanks @muthursyamburi
fix a bug for windows cant create dailyfile dir #77 by @moonrailgun
fixed. no fatal color in colorConsole missed. #79
0.8.11
added fatal level, like log4j. #75 thanks @ds3783
fixed double-log file issue. #71 thanks @huangts
and something missed
0.8.4-0.8.7
added some codes, details: #56 thanks @AmitThakkar
0.8.3
fixed: Got extra data in the log file. #45 thanks @JohnSmithDr
merged: Add Strict mode and EsLint from @HakmiSofian
merged: Change the log to file example to using fs.appendFile() instead. from @twang2218
merged: Enable use of tracer in strict mode from @madarche
merged: Added getter for log level from @ColRad
tested on node.js 4/5
0.8.2
added: Defining a field for max file days filea. #35 thanks @AmitThakkar
0.8.1
added: Adding support for Multiple Transports. #36 thanks @AmitThakkar
fixed: dailyfile auto create folder #37. thanks @klesh
0.8.0
added: setLevel method to dynamically change the log level. thanks @madarche, #30
added: close method to end all of the writable streams. thanks @loht, #31
0.7.4
fixed: use the lastest package of colors v1.0.3.
fixed: removed filter's second parameter
0.7.3
restored: use colors package replace cli-color, because some bugs and a lot of dependencies in cli-color. ref colorConsole2.js example.
0.7.2
fixed: change log dateformat from UTC to LOCAL iso format (Suggest by @felixhao28)
fixed: change color package from colors to cli-color (Suggest by @jeffreydwalter)
0.7.1
added: format add %j placeholder (Thanks @Bacra)
added: add stackIndex opt to specify the index of stack (Thanks @Bacra)
0.7.0
fixed: change inspect format, using new format of node.js 0.10. (Thanks @Bacra)
fixed: now support node.js 0.10 and above, NO Support 0.8 and 0.6
0.6.2
fixed: change stack from array to string, and fixed example2.js
0.6.1
fixed: get the filename correctly on windows. thanks Tom Carchrae
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.