4.1.2 • Published 6 months ago

@metwisom/logger v4.1.2

Weekly downloads
-
License
WTFPL
Repository
github
Last release
6 months ago

Logger

PASS  test/stdout.test.js
logger behaviour
✓ test logger (35 ms)
✓ test prefix (38 ms)
✓ test clone (28 ms)
✓ test level (28 ms)
✓ test log (27 ms)
✓ test warn (25 ms)
✓ test error (28 ms)
Example
import {Logger} from "@metwisom/logger";

const log = new Logger();

log.setPrefix("some Prefix");
log.log("Log line 1");
// "LOG        2024-12-10T10:20:45.242Z - some Prefix - Log line 1"

log.resetPrefix();
log.log("Log line 2");
// "LOG        2024-12-10T10:20:45.242Z - Log line 2"

log.disable();
log.log("Log line 3");
//-- OUTPUT NOTHING --

log.enable();
log.log("Log line 4");
// "LOG        2024-12-10T10:20:45.242Z - Log line 4"

log.error("Error line 5")
// "ERROR      2024-12-10T10:20:45.242Z - Error line 5"

log.warn("Warn line 6")
// "WARN       2024-12-10T10:20:45.242Z - Warn line 6"

log.write("custom","Custom line 7")
// "CUSTOM     2024-12-10T10:20:45.242Z - Custom line 7"

const clone = log.clone()
clone.setPrefix('clone_prefix')
log.write("custom","Custom line 7")
clone.write("custom","Custom line 7")
// "CUSTOM     2024-12-10T10:20:45.242Z - Custom line 7"
// "CUSTOM     2024-12-10T10:20:45.242Z - clone_prefix - Custom line 7"

log.setLevel('warn')
log.log(1)
log.warn(2)
// "WARN       2025-05-05T17:41:00.324Z - 2"
Usages
bun index.ts > log.log 2> err.log
4.0.5

7 months ago

4.0.4

11 months ago

4.1.0

6 months ago

4.0.1

11 months ago

4.0.0

11 months ago

4.1.2

6 months ago

4.0.3

11 months ago

4.1.1

6 months ago

4.0.2

11 months ago

3.0.0

3 years ago

2.0.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago