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

quick-console-log

v1.1.0

Published

Quicklog is a package which overwrites default console.log command to quickly create more sophisticated logs.

Downloads

13

Readme

Quicklog

Github: https://github.com/MichalPlatosz1/Quicklog

npm: https://www.npmjs.com/package/quick-console-log

Quicklog is a package which extends basic console log functions to create more sophisticated logs. It makes it easy to convert your already made console.log's to logs ready for deployment.

Initialization:

require("quick-console-log")

There is no need to assign it to variable as it only updates existing console.log() function

Initial Settings File:

  config: {
    format: `ql_timestamp_ISO  ||  ql_params`,
    timestampFormat: {
      locales: "en-GB",
      options: {
        weekday: "short",
        hour: "numeric",
        minute: "numeric",
        second: "numeric",
      },
    },
    constParams: [`New Entry: `],
    writeToFile: {
      enabled: true,
      logPaths: ["TestLog.log"],
    },
  },

Config files could be accessed by Quicklog object eg: Quicklog.config.writeToFile.enabled = false

Available settings:

format: Specifies logging format, more information can be found below

constParams: You can define list const values to be used in format

timestampFormat: Specifies date format to be used by ql_custom_timestamp more information can be found below

writeToFile:

  • enabled: enables writing console.logs to a file
  • logPaths: array of paths to write logs to if setting is enabled. Paths must include both path to a file and a file name
  • writeObjects: automatically converts javascript objects (includes arrays) to string type and includes it in log files and default output

Format options:

Format can be configured almost without any restrictions. It is represented as a string and you're required to use special tags for dynamic data. All dynamic data specifiers start with "ql_" so it's not recommended to use them as it can cause issues in the future.

  • "console.log has been called" - would result in standard output always displaying the same message despite parameters given to the function.

  • "--> ql_params <--" - would display e.g. "--> Message passed to console.log() <--"

  • "/-\ ql_timestamp_ISO || ql_param1 /-\" - would display e.g. "/-\ 2024-03-07T17:48:29.123Z || sample_message /-" for: console.log("sample_message", "2nd message")

Here are listed all the available dynamic format specifiers:

  • ql_timestamp - displays current date in default Javascript format
  • ql_timestamp_ISO - displays current date in ISO format
  • ql_custom_timestamp - displays date in date format specified inside config.timestampFormat
  • ql_params - displays all props / parameters given to console.log() function e.g. console.log("foo", "bar", {foo: "bar"}) would show up as: "foo", "bar", {foo: "bar"}
  • ql_param[0-9] - displays only given prop, counting up from 0 to 9 e.g. for ql_param2 in Format and while calling function console.log("foo", "bar", {foo: "bar"}) would show up as: {foo: "bar"}
  • ql_const[0-9] - works similary to ql_param[0-9] but instead uses values from config.constParams list

Custom timestamp

you can define format to be used by ql_custom_timestamp string. It uses standard DateTimeFormat settings. You should pass:

{
  locales: string
  options: {}
}

In DateTimeFormat standard which you can read more about

Additional options:

You can prevent console.log() from writing to file only in given situation by passing {exclude: true} in console.log() parameters e.g. console.log("foo", "bar", {exclude: true})