
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
@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
locale: "de-DE", // Optional locale for timestamps
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 |
locale | string | string[] | "en-US" | Locale used for timestamps |
verboseTimer | boolean | false | Show timer start messages |
colors | Partial | - | Custom colors for log levels |
full: full date and timetime: time onlyshort: short date and timeTimestamp output is generated via toLocaleString(locale, ...).
By default, locale is en-US; set locale to customize it.
To keep stack traces, pass the actual Error object to logger.error:
try {
throw new Error("Something failed");
} catch (error: unknown) {
if (error instanceof Error) {
logger.error(error); // preserves stack output
} else {
logger.error(new Error(String(error)));
}
}
If you pass error.message (string) instead, the stack trace is not available.
Timer behavior is consistent whether colors are enabled or disabled:
color: true → colorized timer outputcolor: false → plain timer outputverboseTimer: true → logs start message before duration output// Start a timer
logger.time("operation");
// ... some operations ...
// End the timer and log duration
logger.timeEnd("operation");
The logger provides several debug-specific methods:
// Check if debug mode is enabled
if (logger.isDebugEnabled()) {
// Perform debug-only operations
}
// Start a timer only when debug is enabled
logger.debugTime("debug-operation");
// ... some operations ...
// End the debug timer (only logs when debug is enabled)
logger.debugTimeEnd("debug-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: [02/16/2024, 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
const logger = new Logger("[my-app]", { debug: true });
// Only starts timer if debug is enabled
logger.debugTime("expensive-calculation");
// Some expensive operation
const result = performExpensiveCalculation();
// Only logs time if debug is enabled
logger.debugTimeEnd("expensive-calculation");
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.
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.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.