Socket
Book a DemoInstallSign in
Socket

@tobes31415/console-logger

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tobes31415/console-logger

Formats console logs while preserving stack trace info

2.0.1
latest
Source
npmnpm
Version published
Weekly downloads
102
-57.68%
Maintainers
1
Weekly downloads
 
Created
Source

Console-Logger

A Javascript console log formatter that logs the correct line number. Also supports forking logs to other log reporters so that you can have the benefit of both

View API Docs

Installation

npm install --save @tobes31415/console-logger

Basic Useage

import { createLogFor } from "@tobes31415/console-logger";

const logger = createLogFor("My Module Name");

console.log(...logger("This is a test", 123, "abc"));
// "[My Module Name] 0.5s This is a test", 123, "abc"

Advanced Useage - Forking Log Events

import { onLogEvent } from "@tobes31415-console-logger";

onLogEvent.subscribe(log => {
  //log messages to a server or something
  myServerLogger.log(log.message, ...);
})

Advanced Useage - Customizing the loggers Globally

import { customizeDefaultLogFormatter } from "@tobes31415-console-logger";

customizeDefaultLogFormatter({
   format: {
     uptime: ms => Math.round(ms / 1000) + "s",
   },
   style: {
     uptime: "color:green"
   }
});

Advanced Useage - Customizing individual loggers

import { createLogFor } from "@tobes31415-console-logger";

const logger = createLogFor("My Module Name");

logger.config({
  logThreshold: "warn"
});

console.log(...logger("This does not get logged"));
console.warn(...logger.warn("This one does get logged"));

Thank you

Big thank you to Macadamian Technologies for donating time towards this open source project :-)

Keywords

console

FAQs

Package last updated on 08 May 2023

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.