
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
winston-cfg
Advanced tools
Enables [winston](https://github.com/winstonjs/winston) configuration via [node-config](https://github.com/lorenwest/node-config)
A simple utility that enables winston configuration via node-config
For most common use cases, there are three things that one needs to configure with winston:
winston instantiate a default logger that is configured with a 'Console' transport and set to 'info' level. This can be configured in exactly the same manner as any logger. +-------------------------------------------+
| winston configuration |
+-------------+ | |
| APPLICATION | +----------+ |
| | | +--> | Default +--+ |
| | | | +----------+ | |
| +---------+ | | | +----------+ | +-------------+ |
| | Layer 1 +----------> | Logger 1 +-+--> | Transport A +--------->
| +---------+ | | +----------+ | +-------------+ |
| ... | | | |
| +---------+ | | +----------+ +--> +-------------+ |
| | Layer N +----------> | Logger 1 +----> | Transport B +--------->
| +---------+ | | +----------+ +-------------+ |
+-------------+ | |
| |
+-------------------------------------------+
Please see the interface definition in src/index.ts:Config for details on valid config settings.
And node-config for use of the config module.
// in config/defaults.json
{
"winston": {
"level": "info",
"transports": [{
"type": "Console"
}]
}
}
const log = require('winston-cfg').winstonCfg();
import { winstonCfg } from 'winston-cfg';
const log = winstongCfg();
Since transports may be external modules, winston expects to be provided
instances of transports associated with a logger - global or custom.
We are however attempting to expose only the config capability. As a compromise, winston-cfg adds a 'type' property to the config. The application also has to instantiate a transportMap, which allows the winston-cfg to create
appropriate transports before instantiating loggers.
By default, winston-core supports four transports: Console, File, Http & Memory. Additionally, 3rd-party transports
extend support for other storage mechanisms.
Please see the interface definition in src/index.ts:Config for details on valid config settings.
And node-config for use of the config module.
{
"winston": {
"level": "info",
"transports": [
{
"type": "Console"
},
{
"type": "File",
"filename": "./winston.log"
},
{
"type": "CouchDB",
// ... CouchDb Config.
}
],
"loggers": [{
"id": "app",
"level": "info",
"transports": [{
"type": "SimpleDB",
// ...
}],
}, {
"id": "http"
}]
}
}
// do this in your application startup
import { winstonCfg } from 'winston-cfg';
// import custom transports
import { Couchdb as CouchDB } from 'winston-couchdb';
import { SimpleDB } from 'winston-simpledb';
// prepare a transport map for initialization
const transportMap = {
'CouchDB': CouchDB,
'SimpleDB': SimpleDB
};
// read config and initialize winston appropriately.
// See [node-config](https://github.com/lorenwest/node-config) for details.
const winston = winstonCfg(transportMap);
// get handles to individual loggers
const log = winston; // default logger
const app_log = winston.loggers.get('app');
const http_log = winston.loggers.get('http');
// use log, app_log & http_log as needed.
const logger = 'winston-cfg';
// import custom transports
const CouchDB = require('winston-couchdb').CouchDb;
const SimpleDB = require('winston-simpledb').SimpleDB;
// prepare a transport map for initialization
const transportMap = {
'CouchDB': CouchDB,
'SimpleDB': SimpleDB
};
// read config and initialize winston appropriately.
// See [node-config](https://github.com/lorenwest/node-config) for details.
const winston = winstonCfg(transportMap);
// get handles to individual loggers
const log = winston; // default logger
const app_log = winston.loggers.get('app');
const http_log = winston.loggers.get('http');
// use log, app_log & http_log as needed.
Apache 2.0
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Bugs, PRs, comments, suggestions are all welcomed!
FAQs
Enables [winston](https://github.com/winstonjs/winston) configuration via [node-config](https://github.com/lorenwest/node-config)
The npm package winston-cfg receives a total of 16 weekly downloads. As such, winston-cfg popularity was classified as not popular.
We found that winston-cfg 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
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.