
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
logger-base
Advanced tools
debug module.info, warn & error based from RFC 5424.DEBUG_COLORS by default.debug.duration for measurement.logger-base maintains the highest security standards:
Run security validation: npm run security:validate
$ npm install logger-base --save
Given a code like this one:
const debug = require('logger-base')('metascraper')
debug('retry', { url: 'https://kikobeats.com' })
debug.info('done', { time: Date.now() })
debug.warn('token expired', { timestamp: Date.now() })
debug.error('whoops', { message: 'expected `number`, got `NaN`' })
You can:
DEBUG=logger-base*DEBUG="*,-metascraper:info*" node example.jsSometimes you need to log the duration of a function:
const { setTimeout } = require('timers/promises')
const debug = require('logger-base')('metascraper')
const duration = debug.duration()
setTimeout(1001).then(() => duration.error('timeout!'))
setTimeout(1100).then(() => duration.info('success'))
You can customize the logger behavior with options:
const debug = require('logger-base')('myapp', {
// Custom log levels
levels: ['info', 'warn', 'error', 'fatal'],
// Disable colors
colors: false,
// Custom duration format
durationFormat: (ms) => `${Math.round(ms)}ms`,
// Custom prefix
prefix: (namespace) => `[${namespace}] `,
// Custom encoding (e.g., for structured logging)
encode: (obj) => JSON.stringify(obj)
})
const debug = require('logger-base')('myapp', {
encode: (obj) => {
// Convert object to your preferred format
return Object.entries(obj)
.map(([key, value]) => `${key}="${String(value)}"`)
.join(' ')
}
})
debug('user action', { userId: 123, action: 'login' })
// Output: user action userId="123" action="login"
const debug = require('logger-base')('myapp', {
durationFormat: (ms) => {
if (ms < 1000) return `${ms}ms`
if (ms < 60000) return `${(ms / 1000).toFixed(2)}s`
return `${(ms / 60000).toFixed(2)}m`
}
})
const duration = debug.duration('operation')
// After 1500ms: duration=1.50s
Required
Type: string
The env variable name to use for enabling logging using DEBUG.
Type: object
Default: {}
Configuration options for the debug logger.
Type: array
Default: ['info', 'warn', 'error']
The log levels available. Each level will be accessible as a method on the debug instance (e.g., debug.info(), debug.warn(), debug.error()).
Type: function
Default: The default logfmt encoder
Custom encoding function for converting objects to logfmt format. The function receives an object and should return a logfmt-formatted string.
const debug = require('logger-base')('myapp', {
encode: (obj) => {
// Custom encoding logic
return Object.keys(obj).map(key => `${key}=${obj[key]}`).join(' ')
}
})
Type: boolean
Default: true (unless DEBUG_COLORS=false in environment)
Enable or disable colored output. When disabled, log messages will not include ANSI color codes.
const debug = require('logger-base')('myapp', {
colors: false
})
Type: function
Default: pretty-ms formatter
Custom format function for duration formatting. The function receives a number (milliseconds) and should return a formatted string.
const debug = require('logger-base')('myapp', {
durationFormat: (ms) => {
return `${ms}ms`
}
})
Type: function
Default: The default prefix formatter
Custom prefix function for formatting log messages. The function receives the namespace (string) and color code (number), and should return a formatted prefix string.
const debug = require('logger-base')('myapp', {
prefix: (namespace, color) => {
return `[${namespace}] `
}
})
It returns a function will print the duration in the next call.
const duration = debug.duration('query')
const result = await db.query(query)
duration(result)
logger-base is committed to maintaining the highest security standards. We implement comprehensive security measures including:
# Run comprehensive security validation
npm run security:validate
# Audit all dependencies
npm run security:audit
# Run all security checks (audit + validation)
npm run security:check
Please review our Security Policy for information on reporting vulnerabilities and our response procedures.
logger-base © Kiko Beats, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.
kikobeats.com · GitHub Kiko Beats · X @Kikobeats
FAQs
debug module using logfmt format
The npm package logger-base receives a total of 133 weekly downloads. As such, logger-base popularity was classified as not popular.
We found that logger-base 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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.