New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sumor/logger

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sumor/logger - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

4

package.json
{
"name": "@sumor/logger",
"description": "A Lightweight Logger for Node.js",
"version": "1.0.0",
"description": "This is a lightweight logger for Node.JS. It can output logs in different levels, and you can customize the scope, id, and timezone.",
"version": "1.0.1",
"license": "MIT",

@@ -6,0 +6,0 @@ "repository": "sumor-cloud/logger",

# logger
A [Sumor Cloud](https://sumor.cloud) Tool.
[More Documentation](https://sumor.cloud/logger)
This is a lightweight logger for Node.JS.
It can output logs in different levels, and you can customize the scope, id, and timezone.
[![CI](https://github.com/sumor-cloud/logger/actions/workflows/ci.yml/badge.svg)](https://github.com/sumor-cloud/logger/actions/workflows/ci.yml)

@@ -29,1 +34,68 @@ [![Test](https://github.com/sumor-cloud/logger/actions/workflows/ut.yml/badge.svg)](https://github.com/sumor-cloud/logger/actions/workflows/ut.yml)

## Usage
### General Usage
```js
import Logger from '@sumor/logger';
const logger = new Logger();
logger.trace("Hello World!");
// You will see the following output:
// 2020-01-01 00:00:00.000 TRACE MAIN - Hello World!
```
### Change Scope
For some case, we need categorize logs. `scope` is used for this purpose.
```js
import Logger from '@sumor/logger';
const logger = new Logger({
scope: 'DEMO'
});
logger.trace("Hello World!");
// You will see the following output:
// 2020-01-01 00:00:00.000 TRACE DEMO - Hello World!
```
### Identifier User
For some case, we need identifier user. `id` is used for this purpose.
```js
import Logger from '@sumor/logger';
const logger = new Logger({
id: 'USER001'
});
logger.trace("Hello World!");
// You will see the following output:
// 2020-01-01 00:00:00.000 TRACE MAIN USER001 - Hello World!
```
### Change Level
Most of the time, we only need to output logs of a certain level. Then we can decide if store and display it or not.
```js
import Logger from '@sumor/logger';
const logger = new Logger();
logger.trace("Hello World!"); // trace is the lowest level, all logs will be output
logger.debug("Hello World!");
logger.info("Hello World!");
logger.warn("Hello World!");
logger.error("Hello World!");
logger.fatal("Hello World!"); // fatal is the highest level, only critical error will be output
```
### Change Timezone
```js
import Logger from '@sumor/logger';
const logger1 = new Logger({
offset: 2 * 60 // UTC+2 offset is 2 hours
});
logger1.info("Hello World!");
// You will see the following output:
// 2020-01-01 02:00:00.000 INFO MAIN - Hello World!
const logger2 = new Logger({
offset: 8 * 60 // UTC+8 offset is 8 hours
});
logger2.info("Hello World!");
// You will see the following output:
// 2020-01-01 08:00:00.000 INFO MAIN - Hello World!
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc