
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
#Generate logs in hierarchical tree structure
##Philosophy
##Features
##How to use
logger.log()logger.set()logger._root.traceId to the userlogger._root.toAcyclicJSON() into a database##API
//Creates a new logger. All child loggers will reference this logger in its `_root` property.
//options:
// onLog: called when the log function is called on this or any of its child loggers
// onError: called when error is thrown or promise rejected in this or any of its child loggers
new TreeLog(options) -> logger
//Adds a new child to logger. The `result` property is set to the object / return value
logger.log(message) -> null
logger.log(message, object) -> object
logger.log(message, object, property_name) -> object[property_name]()
logger.log(message, object, property_name, [param_array]) -> object[property_name](param_array...)
//Adds a new child to logger. `func` is called with the new child logger as first parameter
logger.log(message, func) -> func()
//clones value and set it to logger
logger.set(key, value) -> value
//Sets the `result` property. Also updates `elapsedMS` with the time elapsed since logger is created
logger.done(result)
//Returns object with all properties with names beginning with _ stripped out.
logger.toJSON() -> object
//Returns cloned object with all properties with names beginning with _ stripped
//out and all cyclic references converted to string representation.
logger.toJSON() -> object
//Returns string representation of log.
logger.stringify(replacer, spaces)
##Example in CoffeeScript
LogTree = require 'log-tree'
Promise = require 'bluebird'
options =
onLog: (log)-> console.log "[#{log.timestamp}] LOG: #{log.message}"
onError: (log)-> console.log "[#{log.timestamp}] ERR: #{log.message}\n#{log.stack}"
logger = new LogTree('Example', options)
logger.log 'Logging simple objects', process.versions
logger.log 'Nested logging', (logger) ->
logger.log 'Child log 1', (logger) ->
return 'Return value is logged'
logger.log 'Child log 2', (logger, done) ->
done 'Callback value is logged'
return 'Return value is ignored'
try
logger.log 'Logging with error thrown', (logger) ->
throw new Error('Error message')
catch err
#the full log can be found at err.logTree
#also, the error thrown is attached to the log
logger.log 'Logging with promises', (logger) ->
new Promise (resolve, reject) ->
logger.log 'This is the promised child'
setImmediate ()->
resolve 'The resolved value is captured'
return null
.then () ->
logger.log 'This is chained after the previous promise'
console.log 'This is the final tree structure generated'
console.log JSON.stringify logger._root, false, 4
FAQs
Generate logs in hierarchical tree structure
The npm package log-tree receives a total of 2 weekly downloads. As such, log-tree popularity was classified as not popular.
We found that log-tree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.