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

@socio-development/logger

v0.1.0-alpha.0

Published

A logging utility for managing and displaying logs in a structured manner.

Downloads

3

Readme

Logger

This repository contains the Logger class, a utility for managing and displaying logs in a structured manner. The Logger class provides static methods for adding logs with varying levels of indentation, representing nested processes.

Getting started

Run npm i -D @socio-development/logger

Example

import { Logger } from '@socio-development/logger'

const log = new Logger()

log.group('Process: START')
log.add('This is my default log')
log.info('This is my info log')
log.add('This is my default log')
log.warn('This is my warn log')
log.add('This is my default log')
log.error('This is my error log')
log.groupEnd('Process: END')

log.print()

The Logger class is a custom logging utility that provides methods for logging messages with different severity levels and grouping them for better readability.

The script begins by creating a new instance of the Logger class:

const log = new Logger()

Next, it uses the group method to start a new group of log entries:

log.group('Process: START')

The group method logs the provided message and increases the current indentation level. This means that all log entries added after this point will be indented until the group is ended.

The script then uses the add, info, warn, and error methods to log messages with different severity levels:

log.add('This is my default log')
log.info('This is my info log')
log.warn('This is my warn log')
log.error('This is my error log')

Each of these methods creates a new LogEntry with the provided message, the current indentation level, and the appropriate severity level, and adds it to the list of log entries.

Finally, the script uses the groupEnd method to end the current group of log entries and the print method to print all log entries to the console:

log.groupEnd('Process: END')
log.print()

The groupEnd method decreases the current indentation level and logs the provided message, if any. The print method formats all log entries according to the logger's configuration and prints them to the console, separated by newline characters.

Options

You can change the logger output by providing options to the logger.

import { Logger } from '@socio-development/logger'

const log = new Logger({
  // Add your options here
})

Composition

Name .composition

Default

LoggerOptions.composition.default = [
  'timestamp',
  'prefix',
  'indent',
  'message'
]

LoggerOptions.composition.error = [
  'color:red',
  'timestamp',
  'prefix',
  'indent',
  'message',
  'color:reset',
]

LoggerOptions.composition.info = [
  'color:blue',
  'timestamp',
  'prefix',
  'indent',
  'message',
  'color:reset',
]

LoggerOptions.composition.warn = [
  'color:yellow',
  'timestamp',
  'prefix',
  'indent',
  'message',
  'color:reset',
]

The composition option allows you to modify the logger output for each severity level.

Indent size

Name .indentSize

Default 2

Prefix

Name .prefix

Default undefined

Separator

Name .separator

Default ' '

Timestamp format

Name .timestampFormat

Default 'HH:mm:ss'