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

logmark

v1.0.10

Published

Simple, lightweight and dependency free nodejs logger with human-readable logs

Downloads

16

Readme

Simple, lightweight (<5Kb) and dependency free nodejs logger with human-readable logs

Why?

I needed a very simple logger without third-party dependencies, a complex > configuration and with a beautiful human-readable output.

I didn't find it, so I wrote it.


Quick start


Install the library from npm:

npm install logmark

or

yarn add logmark

Logmark supports five levels of logs:

  • debug
  • info
  • warn
  • error
  • fatal

By default, Logmark generates a new 'logs' folder in your project root, and write all logs to a single logs.log file

Let's look at the code below:

import { Logmark } from 'logmark'

const mark = new Logmark()

mark.debug('some debug message')
mark.info('some info message')
mark.warn('some warn message')
mark.error('some error message')
mark.fatal('some fatal message')

Now we can see next terminal output:

'console screen1'

As you can see, Logmark adds local time, pid and memory usage information to each message.

I think the memory usage information is very important, and seeing it in logs is very convenient for tracking memory leaks. It may also make it clear early on that refactoring of some functions is necessary.

Logmark has already created the logs folder and added the logs.log file to it. Let's look at the file output:

'file screen1'

In many cases this is enough for basic use, but you can add a few settings to distribute logs to different files, and you can also attach additional information to messages.


Usage


Config

Let's look how you can set a custom path for the logs folder and file, and distribute logs to different files.

import { Logmark } from 'logmark'

const mark = new Logmark({
  files: {
    enabled: true, // set the value to false to disable logging to files
    pathname: 'custom logs path',
    filename: 'custom logs file'
  }
})

You can also assign a file name for each log level and group logs in any way.

import { Logmark } from 'logmark'

const mark = new Logmark({
  files: {
    enabled: true,
    pathname: 'custom logs path',
    // filename: 'custom logs file'
    filenames: {
      debug: 'डिबग',
      info: '资料',
      warn: 'atención',
      error: 'errors',
      fatal: 'errors'
    }
  }
})

Add tag

You can set a tag to identify the initiator of the message.

import { Logmark } from 'logmark'

const mark = new Logmark()

mark.debug('some debug message', {
  tag: 'server'
})

Console output:

'file screen2'

Add attachment

You can add an any data or error object to your log message

import { Logmark } from 'logmark'

const mark = new Logmark()

mark.info('some debug message', {
  tag: 'server',
  data: { important: 'object' }
})

mark.warn('some debug message', {
  tag: 'server',
  data: 'important string'
})

mark.debug('some debug message', {
  tag: 'server',
  data: 10000
})

mark.error('some debug message', {
  tag: 'server',
  error: new Error('error object')
})

mark.fatal('some debug message', {
  tag: 'server',
  error: new Error('fatal error object')
})

Console output:

'file screen2'

File output:

'file screen2'


Roadmap


I hope to keep developing the library without compromising on its simplicity and minimalism. If there are suggestions, then forks and pull request are welcome!

If you would like to see some functionality, you can open an issue.

I plan to add functionality for daily file rotation in the near future.


Contributing


Use StandardJS style and SonarLint - contributions are welcome!


Support project


If you want to support the project with a small donation for my small contribution to open source, I will be very very happy!

BTC: bc1q4my5g4jf9cy0gzqams9mp06kmyuj59qgpwmrh6
ETH: 0x2C4e8803ecF2E44D55aF615dF8476C786B5b764a
USDT: 0x2C4e8803ecF2E44D55aF615dF8476C786B5b764a
USDC: 0x2C4e8803ecF2E44D55aF615dF8476C786B5b764a

Also, giving me a simple "star" on GitHub is an easy way to support :)

Thanks!