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

tslog78

v1.7.1

Published

TSLog78 arranges different log levels by priority. (TSLog78 按日志优先级安排不同的日志等级)

Downloads

148

Readme

English| 简体中文

License Test Status QQ Group

Feedback QQ Group (Click to join): 323397913

1. TSLOG78 Class Documentation

Overview

TSLOG78 is a class for encapsulating logging functionality, supporting various types of log output including console output, file output, and server-side output. This class uses the singleton pattern to ensure there is only one instance globally and provides methods for setting different log levels.

Installation

npm install TSLOG78

Usage

import TSLOG78 from 'TSLOG78';

const log = TSLOG78.Instance;
log.setup(serverLogger, fileLogger, consoleLogger, 'admin');
log.log('Hello, world!', 50);

Properties

  • debugKind: A list of log debugging kinds used to control which types of logs are recorded.
  • LevelFile, LevelConsole, LevelApi: Respectively represent the threshold levels for file logs, console logs, and API logs. By default, the console log level is 30, the file log level is 50, and the API log level is 70.
  • serverLogger, fileLogger, consoleLogger: Respectively represent the server logger, file logger, and console logger instances.
  • uname: The username, which defaults to an empty string.

Methods

  • setup: Sets up the logger instances.
  • clone: Creates a clone of the current instance.
  • logErr: Logs error messages.
  • log: Logs messages based on the provided parameters. Log levels can be set individually for each class.

Example

import TSLOG78 from 'TSLOG78';
import ServerLOG78 from './ServerLOG78';
import FileLOG78 from './FileLOG78';
import ConsoleLOG78 from './ConsoleLOG78';

const serverLogger = new ServerLOG78();
const fileLogger = new FileLOG78();
const consoleLogger = new ConsoleLOG78();

const log = TSLOG78.Instance;
log.setup(serverLogger, fileLogger, consoleLogger, 'admin');

// Log a message
log.log('This is a log message.', 50); // Both console and file will output because 50 >= 30 && 50 >= 50

// Log an error message
try {
  throw new Error('Something went wrong!');
} catch (error) {
  log.logErr(error);
}

Other

For more detailed information, please refer to the project's GitHub repository or the API documentation.