
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@epdoc/console-logger
Advanced tools
A simple, customizable console logger for Node.js with terminal color support and method chaining.
log.h1('header').info('plain text')log.elapsed().info('Finished')log.mock.enable = true; log.info('test');npm install @epdoc/console-logger
import { Logger } from '@epdoc/console-logger';
// Declare one global logger instance and import it wherever you need to log
const log:LoggerInstance = new Logger({enableStyles:true});
log.info('Hello, world!');
When creating a logger instance, we recommend using:
const log: LoggerInstance = new Logger();
instead of:
const log = new Logger();
The LoggerInstance type includes all the dynamically added style methods (like
h1, h2, text, etc.) that are not part of the original Logger class
definition. These methods are added at runtime, but TypeScript needs to know
about them at compile time.
By using LoggerInstance, you get full type safety and autocompletion for all
logger methods, including the dynamically added ones. This approach combines the
flexibility of runtime method creation with the benefits of static typing.
Runtime loading of methods also allows for custom styles to be added, which is demonstrated in the Custom Styles section below.
The default log level is LogLevel.info. You can change the log level in the
constructor or at any time using the setLevel method.
log.setLevel(LogLevel.debug);
log.debug('Now this debug message will be shown');
You can enable level and time prefixes when initializing the logger:
const log:LoggerInstance = new Logger({ levelPrefix: true, timePrefix: 'local' });
log.info('Hello'); // Outputs: "14:30:45 [INFO] Hello"
The timePrefix can be one of the following values:
'local' - local time'utc' - UTC time'elapsed' - elapsed time since application startfalse - no time prefixA line of output can be built up using method chaining, and is only output when
one of the methods trace, debug, verbose, info or output are
called.
log.text('User:').value('John Doe').info('logged in');
The elapsed time since application start, and the time since the last call to elapsed() can be appended to the output.
log.h1('Starting operation').info();
// ... some code ...
log.tab().text('Operation completed').elapsed().info();
log.indent().info('This is indented by the default 2 spaces');
log.tab().text('This is also indented by 2 spaces').info();
log.indent('>>').info('This is indented by ">> "');
log.indent(4).info('This is indented by 4 spaces');
log.tab(2).text('This is also indented by 4 spaces').info();
log.tab(2).info('This is also indented by 4 spaces');
log.info('This is not indented');
log.h1('Big Header').info('This is a big header');
log.h2('Smaller Header').info('This is a smaller header');
If you want to collect lines for testing or just because, you can use the
setKeepLines method or initialize the logger with keepLines: true.
log.setKeepLines(true);
log.info('Test message');
log.info('Test message 2');
console.log(log.lines); // ['Test message', 'Test message 2']
You can provide your own custom styles when initializing the logger. Here's how:
import { StyleDef, Color } from 'your-logger-package';
const customStyles: Record<string, StyleDef> = {
success: { fg: Color.green },
warning: { fg: Color.yellow },
critical: { fg: Color.red, bg: Color.white },
// Add more custom styles as needed
};
const log:LoggerInstance = new Logger({
level: LogLevel.info,
styles: customStyles
});
log.success('Operation completed successfully');
log.warning('Proceed with caution');
log.critical('System failure detected');
constructor({level: LogLevel = LogLevel.info, keepLines: boolean = false, timePrefix: 'local' | 'utc' | 'elapsed' | false = 'local', levelPrefix: boolean = false})setLevel(level: LogLevel | string): thisgetLevel(): LogLevelisEnabledFor(level: LogLevel): booleansetStyle(style: Style): thisgetStyle(): StylesetLevelPrefix(val: boolean): thissetTimePrefix(val: TimePrefix): thissetElapsed(val: Elapsed): thissetKeepLines(val: boolean): thiselapsed(): thisclearLines(): thisclearLine(): thistext(...args: any[]): thisdata(arg: any): thish1(...args: any[]): thish2(...args: any[]): thish3(...args: any[]): thislabel(...args: any[]): thisaction(...args: any[]): thisvalue(...args: any[]): thispath(...args: any[]): thiscritical(...args: any[]): thisfatal(...args: any[]): thisdata(arg: any): thisstylize(style: StyleName | StyleDef, ...args: any[]): thistab(val: Integer = 2): thisindent(n: Integer = 2): thistrace(...args: any[]): thisdebug(...args: any[]): thisverbose(...args: any[]): thisinfo(...args: any[]): thiswarn(...args: any[]): thiserror(...args: any[]): thisoutput(...args: any[]): thistrace = 1debug = 3verbose = 5info = 7warn = 8error = 9This project is licensed under the MIT License.
FAQs
A simple console logger for Node.js with terminal color support
We found that @epdoc/console-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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.