@hardlydifficult/logger 1.0.6 → 1.0.7
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 +11 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,15 +11,15 @@ npm install @hardlydifficult/logger
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Logger, ConsolePlugin, FilePlugin
|
|
14
|
+
import { Logger, ConsolePlugin, FilePlugin } from "@hardlydifficult/logger";
|
|
15
15
|
|
|
16
16
|
const logger = new Logger("info")
|
|
17
17
|
.use(new ConsolePlugin())
|
|
18
18
|
.use(new FilePlugin("./app.log"));
|
|
19
19
|
|
|
20
20
|
logger.info("Server started", { port: 3000 });
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// Output to console: [2025-01-15T10:30:00.000Z] INFO: Server started {"port":3000}
|
|
22
|
+
// Output to file: {"level":"info","message":"Server started","timestamp":"2025-01-15T10:30:00.000Z","context":{"port":3000}}
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Core Logger
|
|
@@ -79,9 +79,8 @@ The `formatEntry` function is also exported for custom formatting:
|
|
|
79
79
|
|
|
80
80
|
```typescript
|
|
81
81
|
import { formatEntry } from "@hardlydifficult/logger";
|
|
82
|
-
import type { LogEntry } from "@hardlydifficult/logger";
|
|
83
82
|
|
|
84
|
-
const entry
|
|
83
|
+
const entry = {
|
|
85
84
|
level: "warn",
|
|
86
85
|
message: "High memory",
|
|
87
86
|
timestamp: "2025-01-15T10:30:00.000Z",
|
|
@@ -132,11 +131,13 @@ logger.notify("Deployment complete");
|
|
|
132
131
|
|
|
133
132
|
### Behavior
|
|
134
133
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
134
|
+
| Behavior | Description |
|
|
135
|
+
|----------|-------------|
|
|
136
|
+
| Only `warn` and `error` log entries are sent (debug/info are filtered) | |
|
|
137
|
+
| Warn entries use ⚠️ emoji; error entries use 🚨 emoji | |
|
|
138
|
+
| Context is formatted as a JSON code block when present | |
|
|
139
|
+
| `notify()` sends messages directly without level filtering | |
|
|
140
|
+
| If `setSender` is not called, entries are silently dropped | |
|
|
140
141
|
|
|
141
142
|
## Custom Plugins
|
|
142
143
|
|