-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
36 lines (28 loc) · 1013 Bytes
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import FileLogger from "./index.js";
import path from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const logger = new FileLogger('[Example]', path.join(__dirname, 'example.log'));
logger.logInfo('This is an info message');
logger.logDebug('This is a debug message');
logger.logWarn('This is a warning message');
logger.logError('This is an error message');
const someObject = {
foo: 'bar',
baz: 'qux'
};
logger.logInfo(someObject);
logger.logDebug(someObject);
logger.logWarn(someObject);
logger.logError(someObject);
const subLogger = logger.child('[Sub-example]');
subLogger.logInfo('This is an info message');
subLogger.logDebug('This is a debug message');
subLogger.logWarn('This is a warning message');
subLogger.logError('This is an error message');
subLogger.logInfo(someObject);
subLogger.logDebug(someObject);
subLogger.logWarn(someObject);
subLogger.logError(someObject);