@bsb/observable-winston 9.0.0 → 9.1.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 +47 -14
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -7
- package/lib/plugins/observable-winston/index.d.ts +92 -108
- package/lib/plugins/observable-winston/index.js +40 -78
- package/lib/schemas/observable-winston.json +0 -154
- package/lib/schemas/observable-winston.plugin.json +1 -155
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# @bsb/observable-winston
|
|
2
2
|
|
|
3
|
-
Winston observable plugin for BSB
|
|
3
|
+
Winston observable plugin for BSB that integrates with the Winston logging framework.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
|
|
7
|
+
- Full Winston ecosystem support with child loggers
|
|
8
|
+
- Multiple transports: console, file, daily-rotate-file
|
|
9
|
+
- Flexible formatting: JSON, pretty-print, or simple text
|
|
10
|
+
- Per-plugin child loggers for isolated logging
|
|
11
|
+
- Proper error serialization with stack traces
|
|
4
12
|
|
|
5
13
|
## Installation
|
|
6
14
|
|
|
@@ -8,16 +16,10 @@ Winston observable plugin for BSB - integrate with the popular Winston logging f
|
|
|
8
16
|
npm install @bsb/observable-winston
|
|
9
17
|
```
|
|
10
18
|
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
- **Winston integration** - Full Winston ecosystem support
|
|
14
|
-
- **Multiple transports** - Console, file, daily-rotate-file
|
|
15
|
-
- **Flexible formatting** - JSON, pretty-print, or simple text
|
|
16
|
-
- **Child loggers** - Per-plugin Winston loggers
|
|
17
|
-
- **Error serialization** - Proper error stack trace handling
|
|
18
|
-
|
|
19
19
|
## Configuration
|
|
20
20
|
|
|
21
|
+
Add the plugin to your BSB configuration file:
|
|
22
|
+
|
|
21
23
|
```yaml
|
|
22
24
|
plugins:
|
|
23
25
|
observables:
|
|
@@ -51,11 +53,42 @@ plugins:
|
|
|
51
53
|
|
|
52
54
|
### Configuration Options
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
| Option | Description | Default |
|
|
57
|
+
|--------|-------------|---------|
|
|
58
|
+
| `level` | Minimum log level: `error`, `warn`, `info`, `debug` | `info` |
|
|
59
|
+
| `transports.console` | Console output settings | Enabled |
|
|
60
|
+
| `transports.file` | Standard file output with size-based rotation | Disabled |
|
|
61
|
+
| `transports.dailyRotate` | Daily rotating files with retention | Disabled |
|
|
62
|
+
| `format.timestamp` | Include timestamps in logs | `true` |
|
|
63
|
+
| `format.json` | Output in JSON format | `true` |
|
|
64
|
+
| `format.prettyPrint` | Pretty-print JSON output | `false` |
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
Once configured, logs are handled by Winston automatically:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
this.log.info("Service initialized");
|
|
72
|
+
this.log.error("Error occurred", new Error("Something went wrong"));
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Daily Rotation Output
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
logs/
|
|
79
|
+
application-2026-02-04.log
|
|
80
|
+
application-2026-02-03.log.gz
|
|
81
|
+
application-2026-02-02.log.gz
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Documentation
|
|
85
|
+
|
|
86
|
+
Detailed documentation (used by the BSB Registry): `https://github.com/BetterCorp/better-service-base/blob/master/plugins/nodejs/observable-winston/docs/plugin.md`
|
|
87
|
+
|
|
88
|
+
## Links
|
|
89
|
+
|
|
90
|
+
- GitHub: `https://github.com/BetterCorp/better-service-base/tree/master/plugins/nodejs/observable-winston`
|
|
91
|
+
- BSB Registry (package): `https://io.bsbcode.dev/packages/nodejs/@bsb/observable-winston`
|
|
59
92
|
|
|
60
93
|
## License
|
|
61
94
|
|
package/lib/index.d.ts
CHANGED
|
@@ -24,4 +24,4 @@
|
|
|
24
24
|
* You should have received a copy of the GNU Affero General Public License
|
|
25
25
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
26
26
|
*/
|
|
27
|
-
export { WinstonConfigSchema, type WinstonConfig, Config, Plugin, } from "./plugins/observable-winston";
|
|
27
|
+
export { WinstonConfigSchema, type WinstonConfig, Config, Plugin, } from "./plugins/observable-winston/index.js";
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* BSB (Better-Service-Base) is an event-bus based microservice framework.
|
|
4
3
|
* Copyright (C) 2016 - 2025 BetterCorp (PTY) Ltd
|
|
@@ -25,9 +24,4 @@
|
|
|
25
24
|
* You should have received a copy of the GNU Affero General Public License
|
|
26
25
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
27
26
|
*/
|
|
28
|
-
|
|
29
|
-
exports.Plugin = exports.Config = exports.WinstonConfigSchema = void 0;
|
|
30
|
-
var observable_winston_1 = require("./plugins/observable-winston");
|
|
31
|
-
Object.defineProperty(exports, "WinstonConfigSchema", { enumerable: true, get: function () { return observable_winston_1.WinstonConfigSchema; } });
|
|
32
|
-
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return observable_winston_1.Config; } });
|
|
33
|
-
Object.defineProperty(exports, "Plugin", { enumerable: true, get: function () { return observable_winston_1.Plugin; } });
|
|
27
|
+
export { WinstonConfigSchema, Config, Plugin, } from "./plugins/observable-winston/index.js";
|
|
@@ -26,121 +26,105 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import { BSBObservable, BSBObservableConstructor, BSBError } from "@bsb/base";
|
|
28
28
|
import { DTrace, LogMeta } from "@bsb/base";
|
|
29
|
-
import
|
|
30
|
-
import "winston-daily-rotate-file";
|
|
29
|
+
import * as av from "@anyvali/js";
|
|
31
30
|
/**
|
|
32
31
|
* Configuration schema for Winston observable
|
|
33
32
|
*/
|
|
34
|
-
export declare const WinstonConfigSchema:
|
|
35
|
-
level:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
maxFiles: z.ZodDefault<z.ZodString>;
|
|
96
|
-
zippedArchive: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
-
}, z.core.$strip>;
|
|
98
|
-
}, z.core.$strip>;
|
|
99
|
-
format: z.ZodObject<{
|
|
100
|
-
timestamp: z.ZodDefault<z.ZodBoolean>;
|
|
101
|
-
json: z.ZodDefault<z.ZodBoolean>;
|
|
102
|
-
prettyPrint: z.ZodDefault<z.ZodBoolean>;
|
|
103
|
-
}, z.core.$strip>;
|
|
104
|
-
}, z.core.$strip>>;
|
|
33
|
+
export declare const WinstonConfigSchema: av.ObjectSchema<{
|
|
34
|
+
level: av.OptionalSchema<av.EnumSchema<string[]>>;
|
|
35
|
+
transports: av.ObjectSchema<{
|
|
36
|
+
console: av.ObjectSchema<{
|
|
37
|
+
enabled: av.OptionalSchema<av.BoolSchema>;
|
|
38
|
+
colorize: av.OptionalSchema<av.BoolSchema>;
|
|
39
|
+
}>;
|
|
40
|
+
file: av.ObjectSchema<{
|
|
41
|
+
enabled: av.OptionalSchema<av.BoolSchema>;
|
|
42
|
+
filename: av.OptionalSchema<av.StringSchema>;
|
|
43
|
+
maxsize: av.OptionalSchema<av.Int32Schema>;
|
|
44
|
+
maxFiles: av.OptionalSchema<av.Int32Schema>;
|
|
45
|
+
tailable: av.OptionalSchema<av.BoolSchema>;
|
|
46
|
+
}>;
|
|
47
|
+
dailyRotate: av.ObjectSchema<{
|
|
48
|
+
enabled: av.OptionalSchema<av.BoolSchema>;
|
|
49
|
+
dirname: av.OptionalSchema<av.StringSchema>;
|
|
50
|
+
filename: av.OptionalSchema<av.StringSchema>;
|
|
51
|
+
datePattern: av.OptionalSchema<av.StringSchema>;
|
|
52
|
+
maxSize: av.OptionalSchema<av.StringSchema>;
|
|
53
|
+
maxFiles: av.OptionalSchema<av.StringSchema>;
|
|
54
|
+
zippedArchive: av.OptionalSchema<av.BoolSchema>;
|
|
55
|
+
}>;
|
|
56
|
+
}>;
|
|
57
|
+
format: av.ObjectSchema<{
|
|
58
|
+
timestamp: av.OptionalSchema<av.BoolSchema>;
|
|
59
|
+
json: av.OptionalSchema<av.BoolSchema>;
|
|
60
|
+
prettyPrint: av.OptionalSchema<av.BoolSchema>;
|
|
61
|
+
}>;
|
|
62
|
+
}>;
|
|
63
|
+
export type WinstonConfig = av.Infer<typeof WinstonConfigSchema>;
|
|
64
|
+
export declare const Config: import("@bsb/base").BSBPluginConfigClass<av.ObjectSchema<{
|
|
65
|
+
level: av.OptionalSchema<av.EnumSchema<string[]>>;
|
|
66
|
+
transports: av.ObjectSchema<{
|
|
67
|
+
console: av.ObjectSchema<{
|
|
68
|
+
enabled: av.OptionalSchema<av.BoolSchema>;
|
|
69
|
+
colorize: av.OptionalSchema<av.BoolSchema>;
|
|
70
|
+
}>;
|
|
71
|
+
file: av.ObjectSchema<{
|
|
72
|
+
enabled: av.OptionalSchema<av.BoolSchema>;
|
|
73
|
+
filename: av.OptionalSchema<av.StringSchema>;
|
|
74
|
+
maxsize: av.OptionalSchema<av.Int32Schema>;
|
|
75
|
+
maxFiles: av.OptionalSchema<av.Int32Schema>;
|
|
76
|
+
tailable: av.OptionalSchema<av.BoolSchema>;
|
|
77
|
+
}>;
|
|
78
|
+
dailyRotate: av.ObjectSchema<{
|
|
79
|
+
enabled: av.OptionalSchema<av.BoolSchema>;
|
|
80
|
+
dirname: av.OptionalSchema<av.StringSchema>;
|
|
81
|
+
filename: av.OptionalSchema<av.StringSchema>;
|
|
82
|
+
datePattern: av.OptionalSchema<av.StringSchema>;
|
|
83
|
+
maxSize: av.OptionalSchema<av.StringSchema>;
|
|
84
|
+
maxFiles: av.OptionalSchema<av.StringSchema>;
|
|
85
|
+
zippedArchive: av.OptionalSchema<av.BoolSchema>;
|
|
86
|
+
}>;
|
|
87
|
+
}>;
|
|
88
|
+
format: av.ObjectSchema<{
|
|
89
|
+
timestamp: av.OptionalSchema<av.BoolSchema>;
|
|
90
|
+
json: av.OptionalSchema<av.BoolSchema>;
|
|
91
|
+
prettyPrint: av.OptionalSchema<av.BoolSchema>;
|
|
92
|
+
}>;
|
|
93
|
+
}>>;
|
|
105
94
|
/**
|
|
106
95
|
* Winston observable plugin - integrate with Winston logger
|
|
107
96
|
*/
|
|
108
97
|
export declare class Plugin extends BSBObservable<InstanceType<typeof Config>> {
|
|
109
|
-
static Config: import("@bsb/base").BSBPluginConfigClass<
|
|
110
|
-
level:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
timestamp: z.ZodDefault<z.ZodBoolean>;
|
|
140
|
-
json: z.ZodDefault<z.ZodBoolean>;
|
|
141
|
-
prettyPrint: z.ZodDefault<z.ZodBoolean>;
|
|
142
|
-
}, z.core.$strip>;
|
|
143
|
-
}, z.core.$strip>>;
|
|
98
|
+
static Config: import("@bsb/base").BSBPluginConfigClass<av.ObjectSchema<{
|
|
99
|
+
level: av.OptionalSchema<av.EnumSchema<string[]>>;
|
|
100
|
+
transports: av.ObjectSchema<{
|
|
101
|
+
console: av.ObjectSchema<{
|
|
102
|
+
enabled: av.OptionalSchema<av.BoolSchema>;
|
|
103
|
+
colorize: av.OptionalSchema<av.BoolSchema>;
|
|
104
|
+
}>;
|
|
105
|
+
file: av.ObjectSchema<{
|
|
106
|
+
enabled: av.OptionalSchema<av.BoolSchema>;
|
|
107
|
+
filename: av.OptionalSchema<av.StringSchema>;
|
|
108
|
+
maxsize: av.OptionalSchema<av.Int32Schema>;
|
|
109
|
+
maxFiles: av.OptionalSchema<av.Int32Schema>;
|
|
110
|
+
tailable: av.OptionalSchema<av.BoolSchema>;
|
|
111
|
+
}>;
|
|
112
|
+
dailyRotate: av.ObjectSchema<{
|
|
113
|
+
enabled: av.OptionalSchema<av.BoolSchema>;
|
|
114
|
+
dirname: av.OptionalSchema<av.StringSchema>;
|
|
115
|
+
filename: av.OptionalSchema<av.StringSchema>;
|
|
116
|
+
datePattern: av.OptionalSchema<av.StringSchema>;
|
|
117
|
+
maxSize: av.OptionalSchema<av.StringSchema>;
|
|
118
|
+
maxFiles: av.OptionalSchema<av.StringSchema>;
|
|
119
|
+
zippedArchive: av.OptionalSchema<av.BoolSchema>;
|
|
120
|
+
}>;
|
|
121
|
+
}>;
|
|
122
|
+
format: av.ObjectSchema<{
|
|
123
|
+
timestamp: av.OptionalSchema<av.BoolSchema>;
|
|
124
|
+
json: av.OptionalSchema<av.BoolSchema>;
|
|
125
|
+
prettyPrint: av.OptionalSchema<av.BoolSchema>;
|
|
126
|
+
}>;
|
|
127
|
+
}>>;
|
|
144
128
|
private logFormatter;
|
|
145
129
|
private logger;
|
|
146
130
|
private isDisposed;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* BSB (Better-Service-Base) is an event-bus based microservice framework.
|
|
4
3
|
* Copyright (C) 2016 - 2025 BetterCorp (PTY) Ltd
|
|
@@ -25,86 +24,51 @@
|
|
|
25
24
|
* You should have received a copy of the GNU Affero General Public License
|
|
26
25
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
27
26
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
-
}
|
|
34
|
-
Object.defineProperty(o, k2, desc);
|
|
35
|
-
}) : (function(o, m, k, k2) {
|
|
36
|
-
if (k2 === undefined) k2 = k;
|
|
37
|
-
o[k2] = m[k];
|
|
38
|
-
}));
|
|
39
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
-
}) : function(o, v) {
|
|
42
|
-
o["default"] = v;
|
|
43
|
-
});
|
|
44
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
45
|
-
var ownKeys = function(o) {
|
|
46
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
47
|
-
var ar = [];
|
|
48
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
49
|
-
return ar;
|
|
50
|
-
};
|
|
51
|
-
return ownKeys(o);
|
|
52
|
-
};
|
|
53
|
-
return function (mod) {
|
|
54
|
-
if (mod && mod.__esModule) return mod;
|
|
55
|
-
var result = {};
|
|
56
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
57
|
-
__setModuleDefault(result, mod);
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
|
-
})();
|
|
61
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
exports.Plugin = exports.Config = exports.WinstonConfigSchema = void 0;
|
|
63
|
-
const base_1 = require("@bsb/base");
|
|
64
|
-
const zod_1 = require("zod");
|
|
65
|
-
const winston = __importStar(require("winston"));
|
|
66
|
-
require("winston-daily-rotate-file");
|
|
27
|
+
import { BSBObservable, createConfigSchema, LogFormatter, BSBError } from "@bsb/base";
|
|
28
|
+
import * as av from "@anyvali/js";
|
|
29
|
+
import * as winston from "winston";
|
|
30
|
+
import DailyRotateFile from "winston-daily-rotate-file";
|
|
67
31
|
/**
|
|
68
32
|
* Configuration schema for Winston observable
|
|
69
33
|
*/
|
|
70
|
-
|
|
71
|
-
level:
|
|
72
|
-
transports:
|
|
73
|
-
console:
|
|
74
|
-
enabled:
|
|
75
|
-
colorize:
|
|
76
|
-
}),
|
|
77
|
-
file:
|
|
78
|
-
enabled:
|
|
79
|
-
filename:
|
|
80
|
-
maxsize:
|
|
81
|
-
maxFiles:
|
|
82
|
-
tailable:
|
|
83
|
-
}),
|
|
84
|
-
dailyRotate:
|
|
85
|
-
enabled:
|
|
86
|
-
dirname:
|
|
87
|
-
filename:
|
|
88
|
-
datePattern:
|
|
89
|
-
maxSize:
|
|
90
|
-
maxFiles:
|
|
91
|
-
zippedArchive:
|
|
92
|
-
}),
|
|
93
|
-
}),
|
|
94
|
-
format:
|
|
95
|
-
timestamp:
|
|
96
|
-
json:
|
|
97
|
-
prettyPrint:
|
|
98
|
-
}),
|
|
99
|
-
});
|
|
100
|
-
|
|
34
|
+
export const WinstonConfigSchema = av.object({
|
|
35
|
+
level: av.optional(av.enum_(["error", "warn", "info", "debug"])).default("info"),
|
|
36
|
+
transports: av.object({
|
|
37
|
+
console: av.object({
|
|
38
|
+
enabled: av.optional(av.bool()).default(true),
|
|
39
|
+
colorize: av.optional(av.bool()).default(true),
|
|
40
|
+
}, { unknownKeys: "strip" }),
|
|
41
|
+
file: av.object({
|
|
42
|
+
enabled: av.optional(av.bool()).default(false),
|
|
43
|
+
filename: av.optional(av.string()).default("./logs/application.log"),
|
|
44
|
+
maxsize: av.optional(av.int32()).default(10485760),
|
|
45
|
+
maxFiles: av.optional(av.int32()).default(5),
|
|
46
|
+
tailable: av.optional(av.bool()).default(true),
|
|
47
|
+
}, { unknownKeys: "strip" }),
|
|
48
|
+
dailyRotate: av.object({
|
|
49
|
+
enabled: av.optional(av.bool()).default(false),
|
|
50
|
+
dirname: av.optional(av.string()).default("./logs"),
|
|
51
|
+
filename: av.optional(av.string()).default("application-%DATE%.log"),
|
|
52
|
+
datePattern: av.optional(av.string()).default("YYYY-MM-DD"),
|
|
53
|
+
maxSize: av.optional(av.string()).default("20m"),
|
|
54
|
+
maxFiles: av.optional(av.string()).default("14d"),
|
|
55
|
+
zippedArchive: av.optional(av.bool()).default(true),
|
|
56
|
+
}, { unknownKeys: "strip" }),
|
|
57
|
+
}, { unknownKeys: "strip" }),
|
|
58
|
+
format: av.object({
|
|
59
|
+
timestamp: av.optional(av.bool()).default(true),
|
|
60
|
+
json: av.optional(av.bool()).default(true),
|
|
61
|
+
prettyPrint: av.optional(av.bool()).default(false),
|
|
62
|
+
}, { unknownKeys: "strip" }),
|
|
63
|
+
}, { unknownKeys: "strip" });
|
|
64
|
+
export const Config = createConfigSchema({
|
|
101
65
|
name: 'observable-winston',
|
|
102
66
|
description: 'Winston observable plugin with console, file, and rotation transports',
|
|
103
67
|
version: '9.0.0',
|
|
104
68
|
image: './observable-winston.png',
|
|
105
69
|
tags: ['winston', 'logging', 'observability', 'transports'],
|
|
106
70
|
documentation: ['./docs/plugin.md'],
|
|
107
|
-
},
|
|
71
|
+
}, WinstonConfigSchema);
|
|
108
72
|
/**
|
|
109
73
|
* Convert BSB log level to Winston log level
|
|
110
74
|
*/
|
|
@@ -127,9 +91,9 @@ function bsbLevelToWinstonLevel(level) {
|
|
|
127
91
|
/**
|
|
128
92
|
* Winston observable plugin - integrate with Winston logger
|
|
129
93
|
*/
|
|
130
|
-
class Plugin extends
|
|
131
|
-
static Config =
|
|
132
|
-
logFormatter = new
|
|
94
|
+
export class Plugin extends BSBObservable {
|
|
95
|
+
static Config = Config;
|
|
96
|
+
logFormatter = new LogFormatter();
|
|
133
97
|
logger;
|
|
134
98
|
isDisposed = false;
|
|
135
99
|
constructor(config) {
|
|
@@ -157,7 +121,6 @@ class Plugin extends base_1.BSBObservable {
|
|
|
157
121
|
}
|
|
158
122
|
// Daily rotate file transport
|
|
159
123
|
if (this.config.transports.dailyRotate.enabled) {
|
|
160
|
-
const DailyRotateFile = require("winston-daily-rotate-file");
|
|
161
124
|
transports.push(new DailyRotateFile({
|
|
162
125
|
dirname: this.config.transports.dailyRotate.dirname,
|
|
163
126
|
filename: this.config.transports.dailyRotate.filename,
|
|
@@ -230,7 +193,7 @@ class Plugin extends base_1.BSBObservable {
|
|
|
230
193
|
this.sendLog("warn", trace, pluginName, message, meta);
|
|
231
194
|
}
|
|
232
195
|
error(trace, pluginName, message, meta) {
|
|
233
|
-
if (message instanceof
|
|
196
|
+
if (message instanceof BSBError) {
|
|
234
197
|
if (message.raw !== null) {
|
|
235
198
|
this.sendLog("error", message.raw.trace, pluginName, message.raw.message, message.raw.meta);
|
|
236
199
|
}
|
|
@@ -249,4 +212,3 @@ class Plugin extends base_1.BSBObservable {
|
|
|
249
212
|
}
|
|
250
213
|
}
|
|
251
214
|
}
|
|
252
|
-
exports.Plugin = Plugin;
|
|
@@ -2,160 +2,6 @@
|
|
|
2
2
|
"pluginName": "observable-winston",
|
|
3
3
|
"version": "9.0.0",
|
|
4
4
|
"events": {},
|
|
5
|
-
"configSchema": {
|
|
6
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"level": {
|
|
10
|
-
"default": "info",
|
|
11
|
-
"type": "string",
|
|
12
|
-
"enum": [
|
|
13
|
-
"error",
|
|
14
|
-
"warn",
|
|
15
|
-
"info",
|
|
16
|
-
"debug"
|
|
17
|
-
]
|
|
18
|
-
},
|
|
19
|
-
"transports": {
|
|
20
|
-
"type": "object",
|
|
21
|
-
"properties": {
|
|
22
|
-
"console": {
|
|
23
|
-
"type": "object",
|
|
24
|
-
"properties": {
|
|
25
|
-
"enabled": {
|
|
26
|
-
"default": true,
|
|
27
|
-
"type": "boolean"
|
|
28
|
-
},
|
|
29
|
-
"colorize": {
|
|
30
|
-
"default": true,
|
|
31
|
-
"type": "boolean"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"required": [
|
|
35
|
-
"enabled",
|
|
36
|
-
"colorize"
|
|
37
|
-
],
|
|
38
|
-
"additionalProperties": false
|
|
39
|
-
},
|
|
40
|
-
"file": {
|
|
41
|
-
"type": "object",
|
|
42
|
-
"properties": {
|
|
43
|
-
"enabled": {
|
|
44
|
-
"default": false,
|
|
45
|
-
"type": "boolean"
|
|
46
|
-
},
|
|
47
|
-
"filename": {
|
|
48
|
-
"default": "./logs/application.log",
|
|
49
|
-
"type": "string"
|
|
50
|
-
},
|
|
51
|
-
"maxsize": {
|
|
52
|
-
"default": 10485760,
|
|
53
|
-
"type": "integer",
|
|
54
|
-
"minimum": -9007199254740991,
|
|
55
|
-
"maximum": 9007199254740991
|
|
56
|
-
},
|
|
57
|
-
"maxFiles": {
|
|
58
|
-
"default": 5,
|
|
59
|
-
"type": "integer",
|
|
60
|
-
"minimum": -9007199254740991,
|
|
61
|
-
"maximum": 9007199254740991
|
|
62
|
-
},
|
|
63
|
-
"tailable": {
|
|
64
|
-
"default": true,
|
|
65
|
-
"type": "boolean"
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
"required": [
|
|
69
|
-
"enabled",
|
|
70
|
-
"filename",
|
|
71
|
-
"maxsize",
|
|
72
|
-
"maxFiles",
|
|
73
|
-
"tailable"
|
|
74
|
-
],
|
|
75
|
-
"additionalProperties": false
|
|
76
|
-
},
|
|
77
|
-
"dailyRotate": {
|
|
78
|
-
"type": "object",
|
|
79
|
-
"properties": {
|
|
80
|
-
"enabled": {
|
|
81
|
-
"default": false,
|
|
82
|
-
"type": "boolean"
|
|
83
|
-
},
|
|
84
|
-
"dirname": {
|
|
85
|
-
"default": "./logs",
|
|
86
|
-
"type": "string"
|
|
87
|
-
},
|
|
88
|
-
"filename": {
|
|
89
|
-
"default": "application-%DATE%.log",
|
|
90
|
-
"type": "string"
|
|
91
|
-
},
|
|
92
|
-
"datePattern": {
|
|
93
|
-
"default": "YYYY-MM-DD",
|
|
94
|
-
"type": "string"
|
|
95
|
-
},
|
|
96
|
-
"maxSize": {
|
|
97
|
-
"default": "20m",
|
|
98
|
-
"type": "string"
|
|
99
|
-
},
|
|
100
|
-
"maxFiles": {
|
|
101
|
-
"default": "14d",
|
|
102
|
-
"type": "string"
|
|
103
|
-
},
|
|
104
|
-
"zippedArchive": {
|
|
105
|
-
"default": true,
|
|
106
|
-
"type": "boolean"
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
"required": [
|
|
110
|
-
"enabled",
|
|
111
|
-
"dirname",
|
|
112
|
-
"filename",
|
|
113
|
-
"datePattern",
|
|
114
|
-
"maxSize",
|
|
115
|
-
"maxFiles",
|
|
116
|
-
"zippedArchive"
|
|
117
|
-
],
|
|
118
|
-
"additionalProperties": false
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
"required": [
|
|
122
|
-
"console",
|
|
123
|
-
"file",
|
|
124
|
-
"dailyRotate"
|
|
125
|
-
],
|
|
126
|
-
"additionalProperties": false
|
|
127
|
-
},
|
|
128
|
-
"format": {
|
|
129
|
-
"type": "object",
|
|
130
|
-
"properties": {
|
|
131
|
-
"timestamp": {
|
|
132
|
-
"default": true,
|
|
133
|
-
"type": "boolean"
|
|
134
|
-
},
|
|
135
|
-
"json": {
|
|
136
|
-
"default": true,
|
|
137
|
-
"type": "boolean"
|
|
138
|
-
},
|
|
139
|
-
"prettyPrint": {
|
|
140
|
-
"default": false,
|
|
141
|
-
"type": "boolean"
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
"required": [
|
|
145
|
-
"timestamp",
|
|
146
|
-
"json",
|
|
147
|
-
"prettyPrint"
|
|
148
|
-
],
|
|
149
|
-
"additionalProperties": false
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
"required": [
|
|
153
|
-
"level",
|
|
154
|
-
"transports",
|
|
155
|
-
"format"
|
|
156
|
-
],
|
|
157
|
-
"additionalProperties": false
|
|
158
|
-
},
|
|
159
5
|
"pluginType": "observable",
|
|
160
6
|
"capabilities": {
|
|
161
7
|
"logging": {
|
|
@@ -14,159 +14,5 @@
|
|
|
14
14
|
"./docs/plugin.md"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": [],
|
|
17
|
-
"image": "./observable-winston.png"
|
|
18
|
-
"configSchema": {
|
|
19
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
20
|
-
"type": "object",
|
|
21
|
-
"properties": {
|
|
22
|
-
"level": {
|
|
23
|
-
"default": "info",
|
|
24
|
-
"type": "string",
|
|
25
|
-
"enum": [
|
|
26
|
-
"error",
|
|
27
|
-
"warn",
|
|
28
|
-
"info",
|
|
29
|
-
"debug"
|
|
30
|
-
]
|
|
31
|
-
},
|
|
32
|
-
"transports": {
|
|
33
|
-
"type": "object",
|
|
34
|
-
"properties": {
|
|
35
|
-
"console": {
|
|
36
|
-
"type": "object",
|
|
37
|
-
"properties": {
|
|
38
|
-
"enabled": {
|
|
39
|
-
"default": true,
|
|
40
|
-
"type": "boolean"
|
|
41
|
-
},
|
|
42
|
-
"colorize": {
|
|
43
|
-
"default": true,
|
|
44
|
-
"type": "boolean"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"required": [
|
|
48
|
-
"enabled",
|
|
49
|
-
"colorize"
|
|
50
|
-
],
|
|
51
|
-
"additionalProperties": false
|
|
52
|
-
},
|
|
53
|
-
"file": {
|
|
54
|
-
"type": "object",
|
|
55
|
-
"properties": {
|
|
56
|
-
"enabled": {
|
|
57
|
-
"default": false,
|
|
58
|
-
"type": "boolean"
|
|
59
|
-
},
|
|
60
|
-
"filename": {
|
|
61
|
-
"default": "./logs/application.log",
|
|
62
|
-
"type": "string"
|
|
63
|
-
},
|
|
64
|
-
"maxsize": {
|
|
65
|
-
"default": 10485760,
|
|
66
|
-
"type": "integer",
|
|
67
|
-
"minimum": -9007199254740991,
|
|
68
|
-
"maximum": 9007199254740991
|
|
69
|
-
},
|
|
70
|
-
"maxFiles": {
|
|
71
|
-
"default": 5,
|
|
72
|
-
"type": "integer",
|
|
73
|
-
"minimum": -9007199254740991,
|
|
74
|
-
"maximum": 9007199254740991
|
|
75
|
-
},
|
|
76
|
-
"tailable": {
|
|
77
|
-
"default": true,
|
|
78
|
-
"type": "boolean"
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
"required": [
|
|
82
|
-
"enabled",
|
|
83
|
-
"filename",
|
|
84
|
-
"maxsize",
|
|
85
|
-
"maxFiles",
|
|
86
|
-
"tailable"
|
|
87
|
-
],
|
|
88
|
-
"additionalProperties": false
|
|
89
|
-
},
|
|
90
|
-
"dailyRotate": {
|
|
91
|
-
"type": "object",
|
|
92
|
-
"properties": {
|
|
93
|
-
"enabled": {
|
|
94
|
-
"default": false,
|
|
95
|
-
"type": "boolean"
|
|
96
|
-
},
|
|
97
|
-
"dirname": {
|
|
98
|
-
"default": "./logs",
|
|
99
|
-
"type": "string"
|
|
100
|
-
},
|
|
101
|
-
"filename": {
|
|
102
|
-
"default": "application-%DATE%.log",
|
|
103
|
-
"type": "string"
|
|
104
|
-
},
|
|
105
|
-
"datePattern": {
|
|
106
|
-
"default": "YYYY-MM-DD",
|
|
107
|
-
"type": "string"
|
|
108
|
-
},
|
|
109
|
-
"maxSize": {
|
|
110
|
-
"default": "20m",
|
|
111
|
-
"type": "string"
|
|
112
|
-
},
|
|
113
|
-
"maxFiles": {
|
|
114
|
-
"default": "14d",
|
|
115
|
-
"type": "string"
|
|
116
|
-
},
|
|
117
|
-
"zippedArchive": {
|
|
118
|
-
"default": true,
|
|
119
|
-
"type": "boolean"
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
"required": [
|
|
123
|
-
"enabled",
|
|
124
|
-
"dirname",
|
|
125
|
-
"filename",
|
|
126
|
-
"datePattern",
|
|
127
|
-
"maxSize",
|
|
128
|
-
"maxFiles",
|
|
129
|
-
"zippedArchive"
|
|
130
|
-
],
|
|
131
|
-
"additionalProperties": false
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
"required": [
|
|
135
|
-
"console",
|
|
136
|
-
"file",
|
|
137
|
-
"dailyRotate"
|
|
138
|
-
],
|
|
139
|
-
"additionalProperties": false
|
|
140
|
-
},
|
|
141
|
-
"format": {
|
|
142
|
-
"type": "object",
|
|
143
|
-
"properties": {
|
|
144
|
-
"timestamp": {
|
|
145
|
-
"default": true,
|
|
146
|
-
"type": "boolean"
|
|
147
|
-
},
|
|
148
|
-
"json": {
|
|
149
|
-
"default": true,
|
|
150
|
-
"type": "boolean"
|
|
151
|
-
},
|
|
152
|
-
"prettyPrint": {
|
|
153
|
-
"default": false,
|
|
154
|
-
"type": "boolean"
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
"required": [
|
|
158
|
-
"timestamp",
|
|
159
|
-
"json",
|
|
160
|
-
"prettyPrint"
|
|
161
|
-
],
|
|
162
|
-
"additionalProperties": false
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
"required": [
|
|
166
|
-
"level",
|
|
167
|
-
"transports",
|
|
168
|
-
"format"
|
|
169
|
-
],
|
|
170
|
-
"additionalProperties": false
|
|
171
|
-
}
|
|
17
|
+
"image": "./observable-winston.png"
|
|
172
18
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsb/observable-winston",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.1",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"license": "(AGPL-3.0-only OR Commercial)",
|
|
5
6
|
"author": {
|
|
6
7
|
"name": "BetterCorp (PTY) Ltd",
|
|
7
|
-
"email": "
|
|
8
|
+
"email": "ninja@bettercorp.dev",
|
|
8
9
|
"url": "https://bettercorp.dev/"
|
|
9
10
|
},
|
|
10
11
|
"description": "Winston observable plugin for BSB - integrate with Winston logger framework",
|
|
@@ -39,12 +40,12 @@
|
|
|
39
40
|
"@bsb/base": "^9.0.0"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
43
|
+
"@anyvali/js": "^0.2.0",
|
|
42
44
|
"winston": "^3.17.0",
|
|
43
|
-
"winston-daily-rotate-file": "^5.0.0"
|
|
44
|
-
"zod": "^4.3.6"
|
|
45
|
+
"winston-daily-rotate-file": "^5.0.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@bsb/base": "
|
|
48
|
+
"@bsb/base": "^9.0.0",
|
|
48
49
|
"@types/node": "^25.0.0",
|
|
49
50
|
"mocha": "^11.0.0",
|
|
50
51
|
"typescript": "^5.9.0"
|
|
@@ -53,6 +54,5 @@
|
|
|
53
54
|
"node": ">=23.0.0",
|
|
54
55
|
"npm": ">=11.0.0"
|
|
55
56
|
},
|
|
56
|
-
"homepage": "https://io.bsbcode.dev/
|
|
57
|
+
"homepage": "https://io.bsbcode.dev/packages/nodejs/@bsb/observable-winston"
|
|
57
58
|
}
|
|
58
|
-
|