Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
enrise-logger
Advanced tools
A simple wrapper around winston.
NPM: npm install enrise-logger --save
Yarn: yarn add enrise-logger
At the beginning of your application, be sure to initialize the logger:
require('enrise-logger')([config: Object]);
Where config
is an optional object. See below for further instructions.
After the module is initialized, simply call .get(name: String)
on the module to return a namespaced logger:
const log = require('enrise-logger').get('MyLogger');
The log
object contains functions for each log-level:
log.info('Some log message');
log.error(new Error('Some error'));
.get(name: String, [level: String], [transportConfig: Object])
The .get()
function allows additional customization. The level can overwrite the logging-level defined during initialization. A third argument can be passed to overwrite transport configuration. This will be merged onto the object passed to the transports.
The default configuration looks as follows. Everything can be overwritten on initialization.
{
winston: {
transports: {
Console: {
level: 'info',
colorize: true
}
},
levels: {
error: 0,
warn: 1,
help: 2,
data: 3,
info: 4,
trace: 5,
debug: 6,
prompt: 7,
verbose: 8
}
}
}
winston: Object
The top-level key winston
in the config contains winston-specific configuration.
<namedloggerKey>: {level: String}
You can add other toplevel-keys to provide named-logger specific level-information. This functionality allows you to set the log-level through configuration.
{
winston: {...},
namedlogger1: {
level: debug
}
}
The above configuration would set the level
of logging to debug
for the logger which was created as follows:
const log = require('enrise-logger').get('NamedLogger1');
Be aware that the way you'll read and apply your config dictates the actions you should take to change the actual log-level at run-time. If you only read and apply the config at the start of your program you'd have to restart your program to apply the changed log-level.
winston.transports: Object
The keys define the transports that the logger should use, the value is the configuration passed to the transport constructor. Multiple transports can be combined. Defaults to only the Console with the settings above. To exclude the Console transport, set it to null
. Possible transports are:
Console
: winston.Console documentationFile
: winston.File documentationHttp
: winston.Http documentationLogstashUDP
: winston.LogstashUDP documentationwinston.levels
The node-logger uses more detailed log-levels than winston does. The higher the priority the more important the message is considered to be, and the lower the corresponding integer priority. These levels can be modified to your liking.
FAQs
Logger used within Enrise projects and module's
We found that enrise-logger 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.