
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
jlog is a log4j alike logging framework using the concept of handlers, appenders, loggers, log levels and filters. the configuration can be done by a configuration file assigned via an ENV var or directly in the code. The Logging Handlers can be wrappers around any other node logging library like winston or debug.
logger = require('jlog')('logger.name')
logger.debug('debug msg')
logger.error('error msg')
find the log levels at lib/levels.coffee
find implemented handlers at lib/handlers.coffee
if the ENV var JLOG_CONFIG points to an existing file, this configuration is used, otherwise the first file found backwards in the directory tree starting from process cwd with the name jlog_config.json or etc/jlog_config.json is used, otherwise the first file found backwards in the directory tree starting from jlog __dirname with the name jlog_config.json or etc/jlog_config.json is used, otherwise the default configuration is used, that is logging just errors to the console
programmatic configuration is possible by the log manager
logManager = require('jlog/api').logManager
logManager.reConfig({ someConfig })
in the configuration handler part the handlers are configured. each key needs at least a class attribute that is found in lib/handlers
example:
"handler": {
"console": {
"class": "ConsoleHandler",
"formatter": "SimpleFormatter"
},
"winstonFile": {
"class": "WinstonHandler",
"config": {
"file": {
"filename": "winston.log",
"level": "all"
}
}
},
"debug": {
"class": "DebugHandler"
}
The DebugHandler is a wrapper for npm 'debug', the WinstonHandler is a wrapper for npm 'winston' module. the winston config attribute takes any winston configuration.
example:
"logger": [
{"name": "*", "handler": "debug", "level": "debug" },
{"name": "*", "handler": "console", "level": "error" },
{"name": "foo", "handler": "console", "level": "warn" },
{"name": "foo", "handler": "winstonFile", "level": "info" },
{"name": "foo.bar", "handler": "console", "level": "info" },
{"name": "foo.bar.foo.file", "handler": "winstonFile", "level": "debug" }
]
the logger section defines a list of logger names that are assigned to a log handler and a log level. it is logger used, that bests matched the logger name. the matching starts form the beginning of the logger name. if there are more then one best matching loggers found, all matched handlers are used. if no matching logger name is found, the fallback is the logger with the asteriks.
logger1 = require('jlog')('bar.foo')
logger1.debug('is matching the first two entries, logging to handler debug')
logger1.error('is matching the first two entries, logging to handler debug and handler error')
logger2 = require('jlog')('foo.foo.bar')
logger2.info('is matching the 3. and 4. entries, logging to handler winstonFile')
logger2.error('dito, logging to handler console and winstonFile')
logger3 = require('jlog')('foo.bar.foo.file')
logger3.info('is matching the last entries, logging to handler winstonFile')
as convention for logger names it is recommended to use a pattern like
<projectname>.<dirname>[.<filename>]
# run "npm install" once after checkout
# run mocha tests:
npm test
# run samples:
JLOG_CONFIG=<absolute_path_to_dir>/examples/jlog_sample.json coffee examples/jlog_sample.coffee
development is taking place in the coffee files in the src folder. the javascript files are generated into the lib directory with the command:
cake build
FAQs
java like logger
We found that jlog 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
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.