
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@mengkodingan/consolefy
Advanced tools
@mengkodingan/consolefy is a customizable logging library 🙂.
npm i @mengkodingan/consolefy
# or
yarn add @mengkodingan/consolefy
# or
pnpm add @mengkodingan/consolefy
import { Consolefy } from "@mengkodingan/consolefy";
const consolefy = new Consolefy();
consolefy.log("Just a regular log.");
consolefy.info("This is an info log.");
consolefy.success("Operation was successful!");
consolefy.warn("This is a warning.");
consolefy.error("An error occurred.");
You can customize the prefixes, formats, themes, and tags in the consolefy's configuration.
import { Colors, Consolefy } from "@mengkodingan/consolefy";
const consolefy = new Consolefy({
prefixes: {
warn: "Caution",
success: "Done",
error: "Oops",
info: "Heads up",
},
theme: {
warn: (text) => Colors.bgYellow(Colors.black(text)),
success: (text) => Colors.bgGreen(Colors.black(text)),
error: (text) => Colors.bgRed(Colors.black(text)),
info: (text) => Colors.bgBlue(Colors.black(text)),
},
format: "{prefix}{tag} {message}",
tag: "APP",
});
consolefy.info("Info log with custom tag and theme.");
consolefy.success("Custom success log.");
You can also combine both setPrefix() and setTheme() to customize both the prefix and theme for specific log levels dynamically:
import { Colors, Consolefy } from "@mengkodingan/consolefy";
const consolefy = new Consolefy();
// Set a custom prefix and theme for the 'info' log level
consolefy.setPrefix("info", "INFORMATION");
consolefy.setTheme("info", (text) => Colors.bgMagenta(Colors.black(text)));
consolefy.info("This is an informational message with a custom prefix and theme.");
Using setPrefix() and setTheme() methods, you can change the behavior and appearance of your log messages at any point, giving you full flexibility to adapt the logger to different contexts during runtime.
You can group related logs together using the group() and groupEnd() methods.
const consolefy = new Consolefy();
consolefy.group("Initialization");
consolefy.info("Initializing the application...");
consolefy.success("Initialization complete.");
consolefy.groupEnd();
You can define new log levels dynamically by using the defineLogLevel() method.
import { Colors, Consolefy } from "@mengkodingan/consolefy";
const consolefy = new Consolefy();
// Define a new log level "debug"
consolefy.defineLogLevel("debug", { prefix: "DEBUG", theme: (text) => Colors.bgRedBright(Colors.black(text)) });
consolefy.log("debug", "This is a debug message.");
To disable logging output entirely, you can set the logger to silent mode.
const consolefy = new Consolefy();
consolefy.silent(true);
consolefy.info("This log will not be printed because silent mode is enabled.");
consolefy.silent(false);
consolefy.info("This log will be printed.")
You can reset the format and tag back to their default values.
const consolefy = new Consolefy();
// Change the format and tag
consolefy.setFormat("{prefix} - {message}");
consolefy.setTag("CUSTOM_TAG");
// Reset to defaults
consolefy.resetFormat();
consolefy.resetTag();
For more usage examples and demonstrations of different features, please refer to the example/example.ts file.
new Consolefy(config: Config = {})Creates a new instance of the logger with optional configuration.
prefixes: Custom prefixes for different log levels (warn, success, error, info, etc.)format: Custom format for log messages (default: {prefix}{tag} {message})silent: Whether to suppress all logging (default: false)tag: Custom tag to be appended to each log messagetheme: Custom themes for each log level (functions that receive the log message and return the styled message)setConfig(newConfig: Config): voidSets the configuration of the logger.
setPrefix(type: string, prefix: string): voidSets a custom prefix for the specified log level.
setTheme(type: string, theme: (text: string) => string): voidSets a custom theme (color/style) for the specified log level.
setFormat(format: string): voidSets a custom log message format.
resetFormat(): voidResets the log message format to the default.
setTag(tag: string): voidSets a custom tag to be appended to each log message.
resetTag(): voidResets the log tag to the default (empty).
silent(state: boolean): voidEnables or disables silent mode.
defineLogLevel(level: string, options: { prefix: string; theme?: (text: string) => string }): voidDefines a custom log level with a specific prefix and theme.
group(name: string): voidBegins a log group with the given name.
groupEnd(): voidEnds the current log group.
log(level: string, ...messages: any[]): voidLogs a message at the specified log level.
warn(...messages: any[]): voidLogs a warning message.
success(...messages: any[]): voidLogs a success message.
error(...messages: any[]): voidLogs an error message.
info(...messages: any[]): voidLogs an informational message.
FAQs
a customizable logging library.
We found that @mengkodingan/consolefy 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.