Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@alwatr/logger

Package Overview
Dependencies
Maintainers
0
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alwatr/logger

Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.

  • 4.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
670
increased by8.59%
Maintainers
0
Weekly downloads
 
Created
Source

Logger

A lightweight, flexible, and colorful console logging library for TypeScript and ES modules.

Features

  • Customizable Scopes: Organize log messages using scopes for easy filtering and debugging.
  • Colorful Output: Visually distinguish different log levels and scopes with vibrant colors.
  • Debug/Development Mode: Control log verbosity to optimize performance in production environments.
  • Tiny Footprint: Minimal overhead, keeping your project lean and efficient.

Installation

npm install @alwatr/logger

Usage

import { createLogger } from '@alwatr/logger';

const logger = createLogger('my-module'); // Create a logger with a specific scope

function greet(name: string) {
  logger.logMethodArgs?.('greet', { name }); // Log the method call with its arguments
  console.log(`Hello, ${name}!`); 
}

greet('Ali'); 

Log Levels and Methods

  • logProperty(propertyName, value): Logs a property change (useful for tracking state).
  • logFileModule(fileName): Logs the module's file name for easy identification.
  • logMethod(methodName): Logs the entry into a function or method.
  • logMethodArgs(methodName, args): Logs a method call with its arguments.
  • logStep(methodName, stepName, props?): Logs specific steps within a method.
  • logMethodFull(methodName, args, result): Logs a method call with arguments and result.
  • incident(methodName, code, ...args): Logs an event or expected incident (informational).
  • accident(methodName, code, ...args): Logs an unexpected incident or handled error (warning).
  • error(methodName, code, ...args): Logs an unexpected error (critical).
  • logOther(...args): General-purpose logging with styled scope.
  • time(label): Starts a timer.
  • timeEnd(label): Ends a timer and logs the elapsed time.
  • banner(message): Logs a large, prominent banner message.

Enabling Debug Mode

Browser
  1. Open your browser's developer tools.
  2. Go to the "Application" or "Storage" tab.
  3. Find "Local Storage" and locate your application's domain.
  4. Add a new key-value pair: debug with the value 1.
  5. Reload the page.

Or use the following code snippet in the browser console:

window.localStorage?.setItem('debug', '1');

Note: Ensure the browser console's log level is set to include "Verbose" or "All" to see debug messages.

Node.js
DEBUG=1 node index.js

Sponsors

The following companies, organizations, and individuals support Nanolib ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.

Exir Studio

Contributing

Contributions are welcome! Please read our contribution guidelines before submitting a pull request.

License

This project is licensed under the AGPL-3.0 License.

Keywords

FAQs

Package last updated on 10 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc