@wlix/logger 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,21 +6,29 @@ A tiny file-based logger for Node.js projects. It writes logs to daily files and
|
|
|
6
6
|
|
|
7
7
|
- When you create a `Logger`, it ensures the logs directory exists.
|
|
8
8
|
- Each day gets its own log file named `DD-MM-YYYY.log`.
|
|
9
|
-
- Every log line includes UTC time, log level, and your message.
|
|
9
|
+
- Every log line includes UTC time (or UTC offset), log level, and your message.
|
|
10
10
|
- Logs are then written to the file automatically.
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
14
14
|
- Instantiate a new Logger instance.
|
|
15
|
-
- Use `
|
|
15
|
+
- Use the returned function with `"info" | "warn" | "error"` and your message.
|
|
16
16
|
- Files are written to the `./logs` dir by default.
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
import { Logger } from "./Logger";
|
|
20
20
|
|
|
21
|
-
const logger =
|
|
21
|
+
const logger = Logger();
|
|
22
22
|
|
|
23
|
-
logger
|
|
24
|
-
logger
|
|
25
|
-
logger
|
|
23
|
+
logger("info", "Connected to server");
|
|
24
|
+
logger("warn", "Memory is low");
|
|
25
|
+
logger("error", "Something went wrong");
|
|
26
26
|
```
|
|
27
|
+
|
|
28
|
+
## Configuration
|
|
29
|
+
|
|
30
|
+
| Option | Type | Default | Description |
|
|
31
|
+
| ------------- | ----------------------- | ---------- | ---------------------------------------------------------------- |
|
|
32
|
+
| `logsPath` | `string` | `"./logs"` | Path of the directory where log files are stored |
|
|
33
|
+
| `logToStdout` | `boolean` | `true` | Whether to print logs to the console |
|
|
34
|
+
| `timezone` | `"UTC"` \| `UTC±number` | `"UTC"` | Timezone for log timestamps, e.g., `"UTC"`, `"UTC+3"`, `"UTC-6"` |
|