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

@chrisq/logger-js

v1.1.11

Published

Java style logger for es6/node.js/react native logging with easy parameterization of objects.

Downloads

43

Readme

logger-js

Java style logger for es6/node.js/react native logging with easy parameterization of objects.

Parameter {0}, {1}, {2} ... {number} replaced with strings of values of objects(JSON output) or variables passed to function.

By passing objects to the logger when disabled the logging variables are not serialized to strings for logging thus increasing performance while keeping your logging code in place.

For multiple object references to prevent circular printing issues the reference to the first seen object is printed as a quoted string value @ref:/path/to/object or @ref:/path/to/object/array/item/[index]

Prints functions as "[function]", null as "null", undefined as "undefined" unquoted. By default functions are not printed. Text is only quoted if part of a JSON object value.

(https://github.com/chrisjq/logger-js.git)

Usage

Import default logger:

import { Log } from "@chrisq/logger-js"; //For constant instance

import { Logger } from "@chrisq/logger-js"; //For class

Logging

To log

Log.log("{0} componentDidMount - Props: {1}", this.constructor.name, this.props);

To log in class passing class instance variable

const DEBUG_CLASS = true;

...

Log.iLog("{0} componentDidMount - Props: {1}", DEBUG_CLASS, this.constructor.name, this.props);

Constant Log Levels

OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL

Functions

Configuration

  • Log.setCustomLogger(customFunction) - Write a function to log the text in a custom way e.g. write to file. Default is null.
  • Log.setLogLevel(number) - The maximum log level to output to log. Default is ALL(0).
  • Log.setLoggingEnabled(bool) - Enable logging. Default is true.
  • Log.setPrettyJSON(bool) - Pretty print JSON. Default is true.
  • Log.setWriteLevel(bool) - Include the write level in output e.g. INFO:. Default is true.
  • Log.setIncludeTimestamp(bool) - Include time stamp in output. Default is true.
  • Log.setSplitLogCharSize(number) - Set to split a very large log at the specified character count. e.g. Log.setSplitLogCharSize(4000); //Useful for adb logcat so the log isn't truncated. Default is null.
  • Log.setSplitLogCheckNewlineSize(number) - Split on a newline if it is within the character count threshold given. Default is 200 characters.
  • Log.setPrettyNewLine(string) - The newline string to use for pretty JSON. Default is newline character.
  • Log.setPrettyPaddingCount(number) - The pretty printed JSON padding to be added to each level. Default 2
  • Log.setSortObjectKeys(sortEnabledBool, caseInsensitiveBool) - Whether to sort the JSON keys alphabetically and if enabled whether the sort is case sensitive. Default sortEnabledBool = true, caseInsensitiveBool = false
  • Log.setPrettyPrintFunctions(bool) - Pretty print JSON functions as [function]. Default is false.
  • Log.setPrettyPrintNull(bool) - Pretty print JSON nulls as null. Default is true.
  • Log.setPrettyPrintUndefined(bool) - Pretty print JSON undefined as undefined. Default is true.
  • Log.setPrettyPrintIncludeKeyLengthInPadding(bool) - Pretty print JSON, include key length in padding. Default is false.
  • Log.setReplaceSpecialCharacterInJSONString(bool) - Pretty print JSON, replace json special characters \r,\n,\t,\f,\,\v,\b,\0,". Default is false.

Instance Logging:

  • Log.functionName(label, instanceEnable, ...oObj)
  • Log.iSevere()
  • Log.iWarning()
  • Log.iInfo()
  • Log.iConfig()
  • Log.iFine()
  • Log.iFiner()
  • Log.iFinest()
  • Log.iLog() - Same as iInfo

Logging:

  • Log.functionName(label, ...oObj)
  • Log.severe()
  • Log.warning()
  • Log.info()
  • Log.config()
  • Log.fine()
  • Log.finer()
  • Log.finest()
  • Log.log() - Same as info