@diegoso4/simple-logger
v1.1.1
Published
Lightweight, zero-dependency, colorized logger for Node.js and TypeScript
Maintainers
Readme
@diegoso4/simple-logger
Lightweight, zero-dependency, colorized logger for Node.js and TypeScript. Shows caller file, optional function/constructor indicator, and timestamp — without pulling in chalk, winston, or similar.
Features
- Zero runtime dependencies
- Colored output with emoji level indicators
- Caller location (file + line) from stack trace
- Constructor vs function indicator (
🔧/⚙️) - Configurable log levels, colors, and location display
- Respects
NO_COLORfor CI/CD - Full TypeScript types included
Install
pnpm add @diegoso4/simple-logger
# or: npm install @diegoso4/simple-loggerUsage
JavaScript (CommonJS)
const Logger = require('@diegoso4/simple-logger');
Logger.infoLog('Server started');
Logger.successLog('Connected to database');
Logger.warningLog('Cache miss');
Logger.errorLog('Request failed', { status: 500 });
Logger.testLog('Running experiment');
Logger.debugLog('Verbose trace');
Logger.clearLog(); // clears terminalTypeScript (ESM / named imports)
import {
infoLog,
successLog,
warningLog,
errorLog,
testLog,
debugLog,
clearLog,
configureLogger,
} from '@diegoso4/simple-logger';
configureLogger({ minLevel: 'warn', showFullPath: true });
infoLog('This is an info message');
errorLog('Something went wrong', err);Configuration
import { configureLogger } from '@diegoso4/simple-logger';
configureLogger({
minLevel: 'warn', // 'debug' | 'info' | 'warn' | 'error' | 'success' | 'test'
showLocation: true, // show file/line prefix
showFullPath: false, // relative path vs filename only
colors: true, // disable in CI or set NO_COLOR=1
locationWidth: 42, // padding for alignment
});Log methods
| Method | Console | Color | Use case |
|---------------|-----------|--------|-----------------------|
| debugLog | debug | gray | Verbose diagnostics |
| testLog | debug | red | Experiments / dev |
| infoLog | info | cyan | General information |
| successLog | info | green | Positive outcomes |
| warningLog | warn | yellow | Warnings |
| errorLog | error | red | Errors |
| clearLog | — | — | Clear terminal |
Publish (maintainers)
pnpm install
pnpm run build
npm login
npm publish --access publicLicense
MIT © Diego Osorio
