
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.
ts-logger-node
Advanced tools
TS-Logger-Node is a TypeScript library that provides logging functionality with customizable styles and log file management. It allows you to print log messages to the console with various text and background styles, as well as append them to separate log
ts-logger-node is a Node.js logging package that provides a simple yet powerful logging mechanism with customizable log file paths and console output styles. This package is written in TypeScript and comes with type definitions for enhanced development experience.
To install ts-logger-node, you can use npm or yarn:
npm install ts-logger-node
or
yarn add ts-logger-node
To use the logger, import it into your project:
import Logger from "ts-logger-node";
You can log messages with different types: ERROR, GENERAL, or HEADER. The print method is used to log messages, and it takes three arguments:
msg (string): The log message you want to write.type (LogType): The log type, which can be "ERROR", "GENERAL", or "HEADER".options (optional object): Additional options for styling the console output. It contains a style property (string) that accepts ANSI escape sequences for colors and other text styles.Logger.print("This is an error message", "ERROR");
Logger.print("This is a general message", "GENERAL", {
style: textStyles.FgGreen,
});
Logger.print("This is a header message", "HEADER", {
style: textStyles.BgBlue,
});
By default, the log files are stored in the "logs" directory with filenames "general.log" and "error.log". You can customize these file paths using the paths setter:
Logger.paths = {
general: {
dir: "custom-logs/",
fileName: "custom-general",
fileExt: ".log",
},
error: {
dir: "custom-logs/",
fileName: "custom-error",
fileExt: ".log",
},
};
The print method returns a LogReturnType that indicates the status of the log operation. The possible return types are:
"SUCCESS_LOG": The log message was successfully written to the log file and console."ERROR_LOG": The log message was successfully written to the error log file, and the error message was printed to the console."FILE_WRITE_ERROR": There was an error writing the log message to the log file.The package also exports a textStyles object, which provides a set of ANSI escape sequences for styling the console output. You can use these styles in the options.style property to customize the appearance of log messages.
import Logger, { textStyles } from " ts-logger-node";
Logger.print("This text will be blue!", "GENERAL", {
style: textStyles.FgBlue,
});
Logger.print("White text on red background!", "GENERAL", {
styles: {
style: textStyles.BgRed + textStyles.FgWhite,
},
});
Implimenting ts-logger-node can only be done in server-components currently. In order to use Logger, or any other package that requries 'fs', in a NextJS app the a next.config file must include the following:
const nextConfig = {
webpack5: true,
webpack: (config) => {
config.resolve.fallback = { fs: false };
return config;
}
}
If you find any issues with ts-logger-node or want to contribute improvements or new features, please feel free to open an issue or submit a pull request on the GitHub repository.
This package is licensed under the MIT License. See the .LICENSE file for details.
FAQs
TS-Logger-Node is a TypeScript library that provides logging functionality with customizable styles and log file management. It allows you to print log messages to the console with various text and background styles, as well as append them to separate log
We found that ts-logger-node 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.