![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@opuscapita/logger
Advanced tools
Readme
OpusCapita common logging. Wiki at the wiki.
Currently this module is released manually
Versions 1.3.x had an issue where logging logic was reversed (more severe logs not logged while less severe logged).
See https://github.com/OpusCapita/logger/releases
Install logger to your project:
npm install @opuscapita/logger
After that you can directly use the logger component.
const Logger = require('@opuscapita/logger');
const logger = new Logger({context:{name:"My preferably unique logger name"});
logger.info('Hello world!');
logger.trace('Very detailed logs', {details: 'Variable data'});
logger.debug('Detailed logs, normally off', {details: 'Variable data'});
logger.info('Information', {details: 'This is normally logged on production - try to use it only when needed'});
logger.warn('Something wrong but handled', {error: errorThrown, details: 'It is something that is worth looking into but not an issue that require immediate work'});
logger.error('Something bad happened - someone MUST look at it', {details: 'There is a transaction broken or something similar - customer is impacted and someone needs to solve the issue'});
logger.fatal('System is down', {details: 'Use it is major outage happened (and likely system is not reliable)'});
The default configuration object provides hints about what the module's standard behavior is like and which configuration options are available. For further details about the API, please have a look at the wiki.
{
defaultLogLevel : Logger.LogLevel.Info, // Deprecated with no replacement. This states the log level used when using .log() method.
minLogLevel : Logger.LogLevel.Info, // Deprecated - use configuration instead. Logs less severe won't be logged.
outputStreams : { // Output can be streamed to stdout/stderr (default) or any other writeable stream
[Logger.LogLevel.Trace] : process.stdout,
[Logger.LogLevel.Debug] : process.stdout,
[Logger.LogLevel.Info] : process.stdout,
[Logger.LogLevel.Warning] : process.stdout,
[Logger.LogLevel.Error] : process.stderr,
[Logger.LogLevel.Fatal] : process.stderr
},
context : { // Optional context used with every log message
name: null, // Indicate current logger instance
serviceName : Logger.serviceName, // Deprecated - use 'name' instead
serviceInstanceId : 0, // Deprecated - no replacement.
correlationId : null, // Optional. Client request ID.
userId : null, // Optional. User ID.
requestUri : null // Optional. Request URI.
}
}
Note that some settings would become obsolete in the future - logging configuration should be set by the environment, not by code. And the environment is preferably created by a code ;)
logger.log
and instead specify log severity levellogger.json
in your project directory - it would be used on production.etc/logger.json
that takes precedence before logger.json
if found.The first file found - it would be the only used and monitored for changes.
See https://github.com/OpusCapita/logger/wiki/Configuration
{
"serviceName": {
"my service name": "Debug"
},
"name": {
"my preferably unique logger name": "Trace",
"some logger that I am not interested in": "Warning"
},
"requestUri": {
"/api/health/check": "Fatal",
"/api/buggy/endpoint": "Trace"
},
"userId": {
"superduperadmin": "Trace"
},
"default": {
"level": "Info",
"formatter": ""
}
}
The JSON file does NOT support comments by its specification :(
The "formatter" field is optional. When not found (or empty string) then JSON formatter is used. When testing locally you might consider other options that are ci
, ci-wide
, terminal
, color
and color-1line
.
Output contains standard fields and some extra specific to OpusCapita backend:
console
but preferred way is a single object
Module 'correlation-id' is used and it requires node 12.17.0 or newer for node AsyncLocalStorage. Update node to 12.17.0 or newer.
DummyLogger and VerboseLogger were removed. Create a normal logger instance instead like this:
new Logger({level: Logger.LogLevel.Exception)
or
new Logger({level: Logger.LogLevel.Trace})
or even if you must use hardcoded values like -9999
(very silent), 999999
Very verbose, +Infinity
, -Infinity
, ...
debugMode was removed, .setDebugMode
function removed as well.
Remove all references. Do not use - instead just increase log level if needed.
Support for callback as last parameter to log calls was removed (previously deprecated as unsafe). Do not use any longer. If used callbacks are treated as extra arguments to log.
Configuration parameters minLogLevel
and defaultLogLevel
are deprecated and no longer used.
If found in the config file - would be still used for backward compatibility. Rename them to level
If passed in constructor they would be ignored.
Support for custom output streams might be removed in the future (replaced with different implementation). If used - let me know. Otherwise I would try to remove this in version 3.x
Custom log levels are deprecated. Stick with defaults and commonly used levels and you are fine. Change all custom levels to one of the default.
FAQs
Unified logging component for OpusCapita Andariel platform.
The npm package @opuscapita/logger receives a total of 186 weekly downloads. As such, @opuscapita/logger popularity was classified as not popular.
We found that @opuscapita/logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.