zario 0.2.10 → 0.2.11
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/package.json +4 -9
- package/README.npm.md +0 -190
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zario",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "A minimal, fast logging library for Node.js.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"build": "node esbuild.config.js && tsc --emitDeclarationOnly --outDir dist",
|
|
16
|
+
"build": "node -e \"require('fs').rmSync('dist', {recursive:true, force:true})\" && node esbuild.config.js && tsc --emitDeclarationOnly --outDir dist",
|
|
17
17
|
"dev": "tsc --watch",
|
|
18
18
|
"test": "jest",
|
|
19
19
|
"lint": "eslint . --ext .ts,.js",
|
|
20
|
-
"prepublishOnly": "npm run build && node -e \"require('fs').copyFileSync('
|
|
20
|
+
"prepublishOnly": "npm run build && node -e \"require('fs').copyFileSync('RELEASE_README.md', 'README.md')\"",
|
|
21
21
|
"postpublish": "git checkout HEAD -- README.md"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
@@ -52,10 +52,5 @@
|
|
|
52
52
|
"files": [
|
|
53
53
|
"dist/**/*",
|
|
54
54
|
"README.md"
|
|
55
|
-
]
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"@types/express": "^5.0.6",
|
|
58
|
-
"express": "^5.2.1",
|
|
59
|
-
"fastify": "^5.6.2"
|
|
60
|
-
}
|
|
55
|
+
]
|
|
61
56
|
}
|
package/README.npm.md
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
# zario
|
|
2
|
-
|
|
3
|
-
A minimal, fast logging library for Node.js with TypeScript support.
|
|
4
|
-
|
|
5
|
-
## UPDATE 2.9
|
|
6
|
-
|
|
7
|
-
- Added HTTP transport support with new HttpTransport class
|
|
8
|
-
- Added log batching functionality for efficient writes
|
|
9
|
-
- Added compression support (.gz for gzip, .zz for deflate) for rotated files
|
|
10
|
-
- Enhanced rotation with maxSize, maxFiles, and configurable compression
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
npm install zario
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Quick Start
|
|
19
|
-
|
|
20
|
-
```js
|
|
21
|
-
import { Logger, ConsoleTransport } from "zario";
|
|
22
|
-
|
|
23
|
-
const logger = new Logger({
|
|
24
|
-
level: "info",
|
|
25
|
-
colorize: true,
|
|
26
|
-
transports: [new ConsoleTransport()],
|
|
27
|
-
prefix: "[MyApp]",
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Start logging
|
|
31
|
-
logger.info("🚀 Server started on port 3000");
|
|
32
|
-
logger.warn("⚠️ High memory usage detected");
|
|
33
|
-
logger.error("❌ Database connection failed", { code: 500 });
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## API Documentation
|
|
37
|
-
|
|
38
|
-
### Logger Constructor Options
|
|
39
|
-
|
|
40
|
-
| Option | Type | Description |
|
|
41
|
-
| -------------- | -------- | ----------------------- |
|
|
42
|
-
| **level** | `string` | Log level threshold |
|
|
43
|
-
| **json** | `boolean`| Output in JSON format |
|
|
44
|
-
| **timestamp** | `boolean`| Include timestamps |
|
|
45
|
-
| **prefix** | `string` | Prepended label |
|
|
46
|
-
| **transports** | `array` | Where logs are written (with transport-specific options like `path`, `maxSize`, `maxFiles`, `compression`, `batchInterval`, `compressOldFiles` for file transport) |
|
|
47
|
-
| **customLevels** | `object` | Define custom log levels and their priorities |
|
|
48
|
-
| **customColors** | `object` | Assign colors to custom log levels |
|
|
49
|
-
|
|
50
|
-
### Log Levels
|
|
51
|
-
|
|
52
|
-
| Level | Method | Use Case |
|
|
53
|
-
|----------|---------------|----------------------------|
|
|
54
|
-
| 🔍 DEBUG | `logger.debug()` | Detailed debugging info |
|
|
55
|
-
| ✨ INFO | `logger.info()` | General information |
|
|
56
|
-
| ⚠️ WARN | `logger.warn()` | Warning messages |
|
|
57
|
-
| ❌ ERROR | `logger.error()` | Error messages |
|
|
58
|
-
| 🤫 SILENT | `logger.silent()`| Not output to console |
|
|
59
|
-
| 📝 BORING | `logger.boring()`| Lowest priority messages |
|
|
60
|
-
|
|
61
|
-
### Transports
|
|
62
|
-
|
|
63
|
-
#### Console Transport
|
|
64
|
-
```js
|
|
65
|
-
import { Logger, ConsoleTransport } from "zario";
|
|
66
|
-
|
|
67
|
-
const logger = new Logger({
|
|
68
|
-
transports: [
|
|
69
|
-
new ConsoleTransport({ colorize: true })
|
|
70
|
-
]
|
|
71
|
-
});
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
#### File Transport
|
|
75
|
-
```js
|
|
76
|
-
import { Logger, FileTransport } from "zario";
|
|
77
|
-
|
|
78
|
-
const logger = new Logger({
|
|
79
|
-
transports: [
|
|
80
|
-
new FileTransport({
|
|
81
|
-
path: './logs/app.log',
|
|
82
|
-
maxSize: 10485760, // 10MB in bytes
|
|
83
|
-
maxFiles: 5,
|
|
84
|
-
compression: 'gzip', // 'gzip', 'deflate', or 'none' (default: 'none')
|
|
85
|
-
batchInterval: 1000, // Batch interval in ms (0 to disable, default: 0)
|
|
86
|
-
compressOldFiles: true // Whether to compress old files during rotation (default: true)
|
|
87
|
-
})
|
|
88
|
-
]
|
|
89
|
-
});
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
#### HTTP Transport
|
|
93
|
-
```js
|
|
94
|
-
import { Logger, HttpTransport } from "zario";
|
|
95
|
-
|
|
96
|
-
const logger = new Logger({
|
|
97
|
-
transports: [
|
|
98
|
-
new HttpTransport({
|
|
99
|
-
url: 'https://api.example.com/logs',
|
|
100
|
-
method: 'POST',
|
|
101
|
-
headers: {
|
|
102
|
-
'Content-Type': 'application/json',
|
|
103
|
-
'Authorization': 'Bearer your-token-here'
|
|
104
|
-
},
|
|
105
|
-
timeout: 10000, // Request timeout in ms
|
|
106
|
-
retries: 3 // Number of retry attempts
|
|
107
|
-
})
|
|
108
|
-
]
|
|
109
|
-
});
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Methods
|
|
113
|
-
|
|
114
|
-
- `logger.debug(message, metadata?)` - Debug level logging
|
|
115
|
-
- `logger.info(message, metadata?)` - Info level logging
|
|
116
|
-
- `logger.warn(message, metadata?)` - Warning level logging
|
|
117
|
-
- `logger.error(message, metadata?)` - Error level logging
|
|
118
|
-
- `logger.createChild(options)` - Creates a child logger with inherited settings
|
|
119
|
-
- `logger.setLevel(level)` - Change the logger level at runtime
|
|
120
|
-
- `logger.setFormat(format)` - Set the output format to text or json
|
|
121
|
-
|
|
122
|
-
## Usage Examples
|
|
123
|
-
|
|
124
|
-
### Basic Usage
|
|
125
|
-
```js
|
|
126
|
-
import { Logger, ConsoleTransport } from "zario";
|
|
127
|
-
|
|
128
|
-
const logger = new Logger({
|
|
129
|
-
level: "info",
|
|
130
|
-
colorize: true,
|
|
131
|
-
transports: [new ConsoleTransport()]
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
logger.info("Application started");
|
|
135
|
-
logger.error("Something went wrong", { userId: 123 });
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### JSON Format
|
|
139
|
-
```js
|
|
140
|
-
const logger = new Logger({ json: true });
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Custom Levels & Colors
|
|
144
|
-
```js
|
|
145
|
-
import { Logger, ConsoleTransport } from "zario";
|
|
146
|
-
|
|
147
|
-
const logger = new Logger({
|
|
148
|
-
level: 'info',
|
|
149
|
-
customLevels: {
|
|
150
|
-
'success': 6, // Higher priority than error (5).
|
|
151
|
-
'verbose': 1, // Lower priority than debug (2).
|
|
152
|
-
'critical': 7, // Highest priority.
|
|
153
|
-
},
|
|
154
|
-
customColors: {
|
|
155
|
-
'success': 'green',
|
|
156
|
-
'verbose': 'cyan',
|
|
157
|
-
'critical': 'brightRed',
|
|
158
|
-
},
|
|
159
|
-
transports: [
|
|
160
|
-
new ConsoleTransport()
|
|
161
|
-
]
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// Using custom levels.
|
|
165
|
-
logger.logWithLevel('success', 'This is a success message in green!');
|
|
166
|
-
logger.logWithLevel('verbose', 'This is a verbose message in cyan');
|
|
167
|
-
logger.logWithLevel('critical', 'This is a critical message in bright red');
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### Child Loggers
|
|
171
|
-
```js
|
|
172
|
-
const main = new Logger({ prefix: "[APP]" });
|
|
173
|
-
const db = main.createChild({ prefix: "[DB]" });
|
|
174
|
-
|
|
175
|
-
main.info("App initialized");
|
|
176
|
-
db.error("Connection timeout");
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### Multiple Transports
|
|
180
|
-
```js
|
|
181
|
-
import { Logger, ConsoleTransport, FileTransport } from "zario";
|
|
182
|
-
|
|
183
|
-
const logger = new Logger({
|
|
184
|
-
level: 'info',
|
|
185
|
-
transports: [
|
|
186
|
-
new ConsoleTransport(),
|
|
187
|
-
new FileTransport({ path: './logs/app.log' })
|
|
188
|
-
]
|
|
189
|
-
});
|
|
190
|
-
```
|