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

@sap-ux/logger

v0.5.1

Published

A simple logging module

Downloads

530,985

Readme

@sap-ux/logger

This is a simple logging library. It uses Winston underneath to do the heavy-lifting. The API is agnostic to any particular logging library. Don't depend on any Winston-specific implemenation as the underlying library may change in the future.

Quick Usage

Add the package @sap-ux/logger to your project using your preferred package manager.

In Typescript/ES6, import the logger and instantiate it. By default the log level is info and the logs are sent to the console.

import { ToolsLogger } from '@sap-ux/logger';
...

const logger = new ToolsLogger();
...
logger.info('This is an information message');
...
logger.warn('This is a warning');
...
logger.error('This is an error!');
// Can also log objects
logger.debug({a: 42, b: 'some value'});

Logger Options

| Option | Default Value | Description | | ------ | ------------- | ----------- | | logLevel | LogLevel.Info | Log only if equal to or more severe than this level (supported levels) | | transports | ConsoleTransport | An array of transports |

Log Levels

Log levels are exposed an as enumeration. The following levels are available, in decreasing order of severity:

  • Error
  • Warn
  • Info
  • Verbose
  • Debug
  • Silly

Transports

These are the targets of the log messages. You can have multiple targets for a single logger. The targets can be added and removed dynamically, if required.

The following transports are currently supported:

ConsoleTransport

This is used to write to the console.

FileTransport

This is used to write to files. Logs are appended to files. Currently there's no support to rotate logs.

VSCodeTransport

This is used to write to an output channel in VS Code.

NullTransport

This is the equivalent of writing to /dev/null. If an API needs a logger and you really don't want to capture logs, you can use NullTransport to use completely ignore the logs.

Logger API

Logging methods

error(), warn(), info() and debug() methods can be used to either print log a string or an object.

Transport management

You can add(), remove() transport dynamically. transports() returns a list of the current transports of the logger.

Examples

The unit test file can be used as an example to explore the logger's API: ./test/unit/wiston-logger/logger.test.ts

Please refer to the debugging section in the project root README for help debugging the test.

Not supported

The following options are not supported yet. There are no definite plans to add them in the future. They will be considered on a need-basis.

  • Custom formatters
    • VSCodeTransport logs timestamped lines
    • FileTransport logs in JSON
    • ConsoleTransport logs colored and timestamped lines (piping will remove color encoding though)
  • File rotation - the file transport appends to an existing file or creates a new one if missing