npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

m-node-logger

v1.0.5

Published

Marco's Logger for Node.js is a robust and efficient logging solution designed to streamline your logging processes and enhance your application's maintainability.

Downloads

16

Readme

Marco's Logger for Node.js

Marco's Logger for Node.js is a robust and efficient logging solution designed to streamline your logging processes and enhance your application's maintainability. Built on the reliable and widely-used log4js library, Marco's Logger offers advanced features tailored to meet your logging needs.

Key Features:

  • Level Logging System: Easily manage and categorize your logs with multiple levels (e.g., info, warn, error). This allows for more granular control over the logging output, making it simpler to identify and diagnose issues.

  • Console and File Logging: Logs messages both to the console and to files. This dual logging approach ensures you have real-time visibility of your logs and a persistent record for future reference.

  • Daily Log File Creation: Automatically creates new log files on a daily basis. This feature helps you keep your logs organized by date, making it easier to pinpoint when specific events or errors occurred.

  • Easy Integration: Seamlessly integrate Marco's Logger into your existing Node.js application with minimal setup. The package is designed to work out-of-the-box, providing you with instant logging capabilities.

  • Configurable Settings: Customize log file paths, logging levels, and other settings to suit your specific needs. Tailor the logger to match your application's requirements and preferences.

  • Lightweight and Efficient: Built with performance in mind, Marco's Logger adds minimal overhead to your application, ensuring it remains fast and responsive.

  • Enhanced Debugging: Gain deeper insights into your application's behavior with detailed log messages. The logger captures relevant context and timestamps, making debugging more straightforward.

Benefits:

  • Improved Troubleshooting: Quickly identify and resolve issues by reviewing categorized and timestamped log files.
  • Better Organization: Keep your logs neat and orderly with automatic daily log file creation.
  • Increased Control: Adjust logging levels and configurations to meet your specific application needs.
  • Enhanced Maintainability: Maintain cleaner and more manageable code with a structured logging system.
  • Real-Time Visibility: Monitor your application's performance and behavior in real-time through console logging.

How to Use

Step 1: Initialize the Logger

To start using Marco's Logger, you need to initialize it with your preferred settings. Here’s how you can do it:

const logger = require('marcos-logger');

logger.init({
    path: '.',                // Path for saving the log files
    level_error: true,        // Create a separate file for error logs
    level_warning: true,      // Create a separate file for warning logs
    daily: true               // Log files are dated daily
});

Parameters:

  • path: The directory where log files will be saved. Example: path: './logs'.
  • level_error: Boolean flag to create a separate file for error logs. Example: level_error: true.
  • level_warning: Boolean flag to create a separate file for warning logs. Example: level_warning: true.
  • daily: Boolean flag to create daily dated log files. Example: daily: true.

Step 2: Logging Messages

After initialization, you can log messages at various levels:

logger.info('This is an informational message.');
logger.warn('This is a warning message.');
logger.error('This is an error message.');

Step 3: Timing Operations

You can also create labeled timers to measure the duration of operations. The timer logs the start and end times:

logger.time('operation');
// Your code here
logger.timeEnd('operation');

Example Usage:

// Import the logger
const logger = require('marcos-logger');

// Initialize the logger with configuration
logger.init({
    path: './logs',
    level_error: true,
    level_warning: true,
    daily: true
});

// Log some messages
logger.info('Application started.');
logger.warn('This is a warning message.');
logger.error('An error occurred.');

// Measure the time taken for an operation
logger.time('database_query');
// Simulate a database query
setTimeout(() => {
    logger.timeEnd('database_query');
}, 2000);

Elevate your Node.js application's logging capabilities with Marco's Logger, built on the robust log4js foundation. Simplify your debugging process, keep your logs organized, and manage log file storage effortlessly. Install and integrate Marco's Logger today to experience the benefits of efficient and reliable logging.