
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
json-console-logger
Advanced tools
Super light-weight stand-in replacement for console logging to only output JSON
Super light-weight stand-in replacement for console logging to only output JSON
npm install json-console-logger --save
import logger from 'json-console-logger';
logger.log('a string');
// => console.log('{"level":"LOG","message":"a string"}');
logger.log('a string', 'another string');
// => console.log('{"level":"LOG","message":["a string","another string"]}');
logger.info('a string', { an: 'object' });
// => console.info('{"level":"INFO","message":["a string",{"an":"object"}]}');
logger.warn('a string', ['an', 'array']);
// => console.warn('{"level":"WARN","message":["a string",["an","array"]]}');
logger.error('a string', new Error('an error'));
// => console.error('{"level":"ERROR","message":["a string",{"error":"Error","message":"an error","stack":"..."}]}');
import logger from 'json-console-logger';
logger.on('error', (message) => {
// do something
});
logger.error('an error string');
// => console.error('{"level":"ERROR","message":"an error string"}');
// => callback will be called with '{"level":"ERROR","message":"an error string"}' as argument
logger.error('a string', new Error('an error'));
// => console.error('{"level":"ERROR","message":["a string",{"error":"Error","message":"an error","stack":"..."}]}');
// => callback will be called with '{"level":"ERROR","message":["a string",{"error":"Error","message":"an error","stack":"..."}]}' as argument
import logger from 'json-console-logger';
logger.setConfiguration({ log: false, info: false });
logger.log('a string');
// => logs nothing
logger.info('a string');
// => logs nothing
logger.warn('an warn string');
// => console.error('{"level":"WARN","message":"an warn string"}');
logger.error('an error string');
// => console.error('{"level":"ERROR","message":"an error string"}');
console.log
import logger from 'json-console-logger';
logger.setConfiguration({ logger: (msg) => process.stdout.write(`${msg}\n`) });
logger.log('a string');
// => process.stdout.write('{"level":"LOG","message":"a string"}\n');
MIT
FAQs
Super light-weight stand-in replacement for console logging to only output JSON
The npm package json-console-logger receives a total of 1,434 weekly downloads. As such, json-console-logger popularity was classified as popular.
We found that json-console-logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.