Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@brainbits/node-logger
Advanced tools
yarn add @brainbits/node-logger @brainbits/node-logger-formatter-monolog
or
npm install -S @brainbits/node-logger @brainbits/node-logger-formatter-monolog
You have to add a formatter to your package.json
. E. g. the monolog formatter:
"nodeLogger": {
"formatter": "@brainbits/node-node-logger-node-logger-formatter-monolog"
}
You can add more parameters to your "nodeLogger": {}
section.
channel
Channel of the logger (string)
Default: Name of your module
maxLevel
Maximum level (string)
Default:
info
timerLevel
Timer level (string)
Default:
debug
levels
Levels (sorted array)
Default:
'emergency',
'alert',
'critical',
'error',
'warning',
'notice',
'info', // max level default
'debug',
]
outputs
Outputs (object)
Default:
{
emergency: 'stderr',
warning: 'stdout',
}
plugins
Plugins [Optional]
Example
"nodeLogger": {
"plugins": [
"@brainbits/node-node-logger-plugin-<name>"
]
}
formatter
Module name of the formatter (see "Adding a formatter")
You can set your own ENV_VARS
in your package.json with env(<env>, <fallback[optional]>)
Example
"nodeLogger": {
"maxLevel": "env(LOGGER_LEVEL, info)"
}
This will take the value of LOGGER_LEVEL or "info" as fallback. The fallback is optional. If there is no suitable value the default is set.
import { Logger } from '@brainbits/node-logger';
const logger = new Logger();
import { Logger } from '@brainbits/node-logger';
const config = {
maxLevel: 'error',
level: [
'error',
'info',
'debug',
],
formatter: (event) => {
console.log(event)
}
};
const logger = new Logger(config);
First argument is a string to define your context.
Second argument is the entire configration object. You can override the configuration in your package.json
here.
import Logger from '@brainbits/node-logger';
const logger = new Logger();
const meta = {
foo: 'bar';
};
logger.info('This is my message', meta);
There is a timer function logger.start(<message>)
import { logger } from '@brainbits/node-logger';
const meta = {
foo: 'bar';
};
logger.start('timer');
//... somewhere else in your code ...
function loadAsyncShit() {
return fetch('https://api/resource?query=blah')
.then(result => {
logger.stop('timer', meta);
return result;
};
};
// Could output: [2010-01-31 23:59:59] module.DEBUG: timer {"foo":"bar","timeMs":75} []
logger.<level>(<message>, <meta>)
<level>
Pick one of these levels (default):
emergency
alert
critical
error
warning
notice
info
debug
(default: no ouput [maxLevel])<message>
Message can be a string
, array
or object
(and Error
object)
<meta>
Must be an object. Used for additional context data.
logger.info('This is my message', { foo: 'bar' });
Caution: If message is an object and meta has the same property, meta will override this property.
FAQs
Logger for node projects
The npm package @brainbits/node-logger receives a total of 183 weekly downloads. As such, @brainbits/node-logger popularity was classified as not popular.
We found that @brainbits/node-logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.