
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
@kocal/logger
Advanced tools
The Node.js logger I have always dreamed of.
$ yarn add @kocal/logger
import { Logger } from '@kocal/logger';
// or
const { Logger } = require('@kocal/logger');
// Default logger
const logger = Logger.getLogger();
logger.debug('My message');
// Write `2019-01-15T12:30:10.000Z:: default :: debug :: My message`
logger.log('My message');
// Write `2019-01-15T12:30:10.000Z :: default :: log :: My message`
logger.info('My message');
// Write `2019-01-15T12:30:10.000Z :: info :: My message`
logger.warn('My message');
// Write `2019-01-15T12:30:10.000Z :: default :: warn :: My message`
logger.error('My message');
// Write `2019-01-15T12:30:10.000Z :: default :: error :: My message`
// Named logger
const namedLogger = Logger.getLogger('my-name');
namedLogger.debug('My message');
// Write `2019-01-15T12:30:10.000Z :: my-name :: debug :: My message`
Available levels are:
// at initialization
const logger = Logger.getLogger('my-logger', {
level: 'info',
});
// at runtime
logger.level = 'info';
// or
logger.setLevel('info');
// will display something
logger.error('Message');
logger.warn('Message');
logger.info('Message');
// won't display anything
logger.log('Message');
logger.debug('Message');
The default format is: Date.toISOString() :: loggerName :: levelColor(level) :: message.
You can override the format at any moment by calling logger.setFormat():
const logger = Logger.getLogger();
logger.format = (context, variables) => {
return `${context.date.toISOString()} :: ${context.message}`
}
// or
logger.setFormat((context, variables) => {
return `${context.date.toISOString()} :: ${context.message}`
})
logger.log('My message');
// Write `2019-01-15T12:30:10.000Z :: My message`
In version 2.0, Luxon dependency has been removed because its weight is about ~85kB, and ~77% of the size of the logger is due to Luxon.
To format the date, you can use date-fns format method:
import { Logger } from '@kocal/logger';
import { format as formatDate } from 'date-fns';
const logger = Logger.getLogger();
logger.format = (context, variables) => {
return `${formatDate(context.date, 'YYYY-MM-DD HH:mm:ss')} :: ${context.message}`;
}
logger.log('My message');
// Write `2019-01-15 13:13:10 :: My message`
You can specify static or dynamic variables like that:
const logger = Logger.getLogger();
logger.format = (context, variables) => {
return `${context.date} :: ${context.message} :: vars = ${JSON.stringify(variables)}`;
}
// pass a plain object
logger.variables = { count: 9000, foo: 'bar' }
// or a function that will be called at each time you log something
let anotherVariable = 'bar';
logger.variables = () => ({ count: 9000, foo: anotherVariable });
// or
logger.setVariables({ count: 9000, foo: 'bar' })
logger.setVariables(() => ({ count: 9000, foo: anotherVariable }))
logger.log('My message');
// Write `2019-01-15T12:30:10.000Z :: My message :: vars = {"count":9000,"foo":"bar"}`
All logs methods have a 2nd parameters where you can pass additional variables:
// pass a plain object
logger.log('My message', { count: 1234 });
// Write `2019-01-15T12:30:10.000Z :: My message :: vars = {"count":1234,"foo":"bar"}`
// or a function
logger.log('My message', () => ({ count: 1234 }));
// Write `2019-01-15T12:30:10.000Z :: My message :: vars = {"count":1234,"foo":"bar"}`
.getLogger( name = 'default', options = {}): LoggerReturns a singleton.
Parameters:
name: A name, 'default' by defaultoptions:
options.format: check .setFormatoptions.variables check setVariables.setFormat( (context, variables) => '...' ): voidCustomize log messages format.
Parameters:
context:
context.name: logger's name, 'default' by defaultcontext.level: 'debug', 'log', 'info', 'warn', or 'error'context.levelColor: the color that represents levelcontext.message: your messagecontext.chalk: an instance of chalkcontext.date: an instance of Datevariables: a fusion of variables defined with .setVariables and additional variables from logging methods.debug( message, additionalVariables = {} | Function ): void.log( message, additionalVariables = {} | Function ): void.info( message, additionalVariables = {} | Function ): void.warn( message, additionalVariables = {} | Function ): void.error( message, additionalVariables = {} | Function ): voidLog a message.
Parameters:
message: your message 🤷🏻additionalVariables: variables that will be merged with logger's variables.FAQs
The Node.js logger I have always dreamed of
The npm package @kocal/logger receives a total of 5 weekly downloads. As such, @kocal/logger popularity was classified as not popular.
We found that @kocal/logger 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
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.