
Company News
Socket Named to Rising in Cyber 2026 List of Top Cybersecurity Startups
Socket was named to the Rising in Cyber 2026 list, recognizing 30 private cybersecurity startups selected by CISOs and security executives.
pretty-logger-js
Advanced tools
Lightweight, customizable Node.js logging module with multiple transports and formatters.
A lightweight, logging module that provides a plug-in style transmission and formatter.
debug → info → warn → error → silentconst { logger } = require('./pretty-logger-js');
logger.info('Server started', { port: 3000 });
logger.warn('High memory', { mb: 512 });
logger.error('DB failed', { host: 'localhost' });
Set the minimum level via the LOG_LEVEL environment variable (default: info):
LOG_LEVEL=debug node app.js
const {
Logger,
createConsoleTransport,
createFileTransport,
colorFormatter,
jsonFormatter,
} = require('./pretty-logger-js');
const logger = new Logger({
level: 'debug',
name: 'my-app', // added to every log entry's meta
transports: [
createConsoleTransport({ formatter: colorFormatter }),
createFileTransport({
filePath: './logs/app.log',
formatter: jsonFormatter,
maxBytes: 10 * 1024 * 1024, // 10 MB → then rotate
maxFiles: 5, // keep 5 rotated files
}),
],
});
Inherit all settings but inject extra metadata into every entry:
// In your request middleware:
const reqLogger = logger.child({ requestId: req.id, userId: req.user.id });
reqLogger.info('Request received', { method: req.method, path: req.path });
// → meta always contains requestId and userId
Send logs to an external endpoint (e.g. a log aggregator):
const { createHttpTransport } = require('./pretty-logger-js');
const logger = new Logger({
transports: [
createHttpTransport({
url: 'https://logs.example.com/ingest',
headers: { Authorization: 'Bearer MY_TOKEN' },
levels: ['error', 'warn'], // only send errors and warnings
timeout: 3000,
}),
],
});
// Silence all logs (e.g. in tests)
logger.setLevel('silent');
// Re-enable
logger.setLevel('info');
// Add a transport after creation
logger.addTransport(createFileTransport({ filePath: './debug.log' }));
// Remove a transport by name
logger.removeTransport('file');
| Formatter | Output | Best for |
|---|---|---|
colorFormatter | [timestamp] [INFO ] message {"key":"value"} (ANSI colors) | Dev console |
plainFormatter | [timestamp] [INFO ] message {"key":"value"} (no color) | File output |
jsonFormatter | {"timestamp":"...","level":"info","message":"...","meta":{...}} | Production / log aggregators |
A formatter is just a function — write your own:
function myFormatter(level, message, meta) {
return `${level.toUpperCase()} | ${message} | ${JSON.stringify(meta)}`;
}
createConsoleTransport({ formatter: myFormatter });
new Logger(options)| Option | Type | Default | Description |
|---|---|---|---|
level | string | 'info' | Minimum level to emit |
transports | array | [] | Transport objects |
defaultMeta | object | {} | Merged into every log entry's meta |
name | string | — | Added as meta.logger |
logger.log(level, message, meta?)logger.debug/info/warn/error(message, meta?)logger.child(meta) → Loggerlogger.setLevel(level)logger.addTransport(transport)logger.removeTransport(name)pretty-logger-js/
index.js ← public API + default instance
logger.js ← Logger class
formatter.js ← plain, color, JSON formatters
transports/
console.js ← stdout/stderr transport
file.js ← file transport with rotation
http.js ← HTTP/HTTPS POST transport
examples/
basic.js ← simple usage
advanced.js ← full feature demo
README.md
package.json
node examples/basic.js
node examples/advanced.js
Logs written to files will appear in ./logs/.
MIT
FAQs
Lightweight, customizable Node.js logging module with multiple transports and formatters.
The npm package pretty-logger-js receives a total of 43 weekly downloads. As such, pretty-logger-js popularity was classified as not popular.
We found that pretty-logger-js demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Company News
Socket was named to the Rising in Cyber 2026 list, recognizing 30 private cybersecurity startups selected by CISOs and security executives.

Research
Socket detected 84 compromised TanStack npm package artifacts modified with suspected CI credential-stealing malware.

Security News
A dispute over fsnotify maintainer access set off supply chain alarms around one of Go’s most widely used filesystem libraries.