
Security News
PolinRider: North Korea-Linked Supply Chain Campaign Expands Across Open Source Ecosystems
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.
@ecopages/logger
Advanced tools
A lightweight, flexible logging library with color support, timestamps, and timer functionality. This logger supports multiple log levels and allows for easy extension and integration into any project.
A lightweight, flexible logging library with color support, timestamps, and timer functionality. This logger supports multiple log levels and allows for easy extension and integration into any project.
INFO, ERROR, WARN, and DEBUG log levelsnpm install @ecopages/logger
# or
yarn add @ecopages/logger
# or
bun add @ecopages/logger
import { Logger } from "@ecopages/logger";
// Create a basic logger
const logger = new Logger("[my-app]");
// Log messages at different levels
logger.info("This is an informational message");
logger.warn("This is a warning message");
logger.error("This is an error message");
logger.debug("This is a debug message"); // Only shown if debug is enabled
The logger supports various configuration options:
const logger = new Logger("[my-app]", {
debug: true, // Enable debug messages
color: true, // Enable colored output
timestamp: true, // Add timestamps to messages
timestampFormat: 'full', // Configure timestamp format
verboseTimer: true, // Show timer start messages
colors: { // Custom colors
INFO: 'color: purple',
ERROR: 'color: darkred'
}
});
| Option | Type | Default | Description |
|---|---|---|---|
debug | boolean | false | Enable debug level messages |
color | boolean | true | Enable colored output |
timestamp | boolean | false | Add timestamps to messages |
timestampFormat | 'full' | 'time' | 'short' | 'time' | Timestamp format |
verboseTimer | boolean | false | Show timer start messages |
colors | Partial | - | Custom colors for log levels |
full: YYYY-MM-DD HH:mm:sstime: HH:mm:ssshort: MM-DD HH:mm:ss// Start a timer
logger.time("operation");
// ... some operations ...
// End the timer and log duration
logger.timeEnd("operation");
Colors can be customized differently for browser and Node.js environments:
// Browser colors (CSS syntax)
const logger = new Logger("[my-app]", {
colors: {
INFO: 'color: purple',
ERROR: 'color: darkred',
WARN: 'color: orange',
DEBUG: 'color: cyan',
TIMER: 'color: magenta'
}
});
// Node.js colors (ANSI codes)
const logger = new Logger("[my-app]", {
colors: {
INFO: '\x1b[35m', // Purple
ERROR: '\x1b[31m', // Red
WARN: '\x1b[33m', // Yellow
DEBUG: '\x1b[36m', // Cyan
TIMER: '\x1b[35m' // Magenta
}
});
const logger = new Logger("[my-app]", {
timestamp: true,
timestampFormat: 'full'
});
logger.info("Application started");
// Output: [2024-02-16 15:30:45] [my-app] Application started
const logger = new Logger("[my-app]", { debug: true });
logger.debug("Configuration loaded:", { port: 3000 });
// Output: [my-app] Configuration loaded: { port: 3000 }
const logger = new Logger("[my-app]", { verboseTimer: true });
logger.time("db-query");
// ... database operation ...
logger.timeEnd("db-query");
// Output: [my-app] db-query: 123.45ms
FAQs
A lightweight, flexible logging library with color support, timestamps, and timer functionality. This logger supports multiple log levels and allows for easy extension and integration into any project.
The npm package @ecopages/logger receives a total of 185 weekly downloads. As such, @ecopages/logger popularity was classified as not popular.
We found that @ecopages/logger 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
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.

Security News
Open source attacks are accelerating as AI coding agents pull in dependencies faster, with less human review.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.