vona-module-a-logger 5.0.23 → 5.0.25
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/dist/.metadata/index.d.ts +3 -0
- package/dist/bean/bean.logger.d.ts +9 -2
- package/dist/index.js +56 -2
- package/dist/main.d.ts +8 -0
- package/package.json +4 -2
|
@@ -79,6 +79,9 @@ export interface IModuleBroadcast {
|
|
|
79
79
|
'setLevel': BroadcastSetLevel;
|
|
80
80
|
}
|
|
81
81
|
/** broadcast: end */
|
|
82
|
+
/** main: begin */
|
|
83
|
+
export * from '../main.ts';
|
|
84
|
+
/** main: end */
|
|
82
85
|
/** scope: begin */
|
|
83
86
|
import { BeanScopeBase, type BeanScopeUtil } from 'vona';
|
|
84
87
|
export declare class ScopeModuleALogger extends BeanScopeBase {
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import type { ILoggerClientRecord, LoggerLevel } from 'vona';
|
|
1
|
+
import type { ILoggerChildRecord, ILoggerClientRecord, ILoggerOptionsClientInfo, LoggerLevel } from 'vona';
|
|
2
|
+
import type * as Transport from 'winston-transport';
|
|
2
3
|
import { BeanBase } from 'vona';
|
|
4
|
+
import * as Winston from 'winston';
|
|
3
5
|
export declare class BeanLogger extends BeanBase {
|
|
4
|
-
getLevel(clientName?: keyof ILoggerClientRecord): LoggerLevel |
|
|
6
|
+
getLevel(clientName?: keyof ILoggerClientRecord): LoggerLevel | false;
|
|
5
7
|
setLevel(level: LoggerLevel | boolean, clientName?: keyof ILoggerClientRecord): void;
|
|
8
|
+
get default(): Winston.Logger;
|
|
9
|
+
getClient(clientName?: keyof ILoggerClientRecord): Winston.Logger;
|
|
10
|
+
getChild(childName: keyof ILoggerChildRecord, clientName?: keyof ILoggerClientRecord): Winston.Logger;
|
|
11
|
+
makeTransportFile(clientInfo: ILoggerOptionsClientInfo, fileName: string, levelStrict?: LoggerLevel): Transport;
|
|
12
|
+
makeTransportConsole(clientInfo: ILoggerOptionsClientInfo): Transport | undefined;
|
|
6
13
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { BeanInfo, BeanBase, BeanAopMethodBase, SymbolBeanFullName, cast, BeanScopeBase } from 'vona';
|
|
1
|
+
import { BeanInfo, BeanBase, BeanAopMethodBase, SymbolBeanFullName, cast, formatLoggerFilter, formatLoggerConsole, BeanSimple, combineConfigDefault, deepExtend, BeanScopeBase } from 'vona';
|
|
2
2
|
import StdSerializers from 'pino-std-serializers';
|
|
3
3
|
import { MiddlewareSystem, AopMethod } from 'vona-module-a-aspect';
|
|
4
4
|
import { evaluateExpressions } from '@cabloy/utils';
|
|
5
5
|
import { Bean, Scope } from 'vona-module-a-bean';
|
|
6
|
+
import * as Winston from 'winston';
|
|
6
7
|
import { Broadcast, BeanBroadcastBase } from 'vona-module-a-broadcast';
|
|
7
8
|
|
|
8
9
|
var _dec$4, _dec2$4, _class$4;
|
|
@@ -152,6 +153,37 @@ let BeanLogger = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
|
|
|
152
153
|
clientName
|
|
153
154
|
});
|
|
154
155
|
}
|
|
156
|
+
get default() {
|
|
157
|
+
return this.app.meta.logger.get();
|
|
158
|
+
}
|
|
159
|
+
getClient(clientName) {
|
|
160
|
+
return this.app.meta.logger.get(clientName);
|
|
161
|
+
}
|
|
162
|
+
getChild(childName, clientName) {
|
|
163
|
+
return this.app.meta.logger.get(clientName).child({
|
|
164
|
+
name: childName
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
makeTransportFile(clientInfo, fileName, levelStrict) {
|
|
168
|
+
return this.app.meta.logger.createTransportFile(fileName, clientInfo, {
|
|
169
|
+
level: levelStrict ?? 'silly',
|
|
170
|
+
format: Winston.format.combine(formatLoggerFilter({
|
|
171
|
+
level: levelStrict ?? clientInfo.level,
|
|
172
|
+
strict: !!levelStrict
|
|
173
|
+
}), Winston.format.json())
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
makeTransportConsole(clientInfo) {
|
|
177
|
+
if (this.app.meta.env.LOGGER_DUMMY === 'true') return;
|
|
178
|
+
return new Winston.transports.Console({
|
|
179
|
+
level: 'silly',
|
|
180
|
+
format: Winston.format.combine(formatLoggerFilter({
|
|
181
|
+
level: clientInfo.level,
|
|
182
|
+
silly: true
|
|
183
|
+
}), Winston.format.colorize(), formatLoggerConsole(clientInfo)),
|
|
184
|
+
forceConsole: true
|
|
185
|
+
});
|
|
186
|
+
}
|
|
155
187
|
}) || _class$2) || _class$2);
|
|
156
188
|
|
|
157
189
|
var _dec$1, _dec2$1, _class$1;
|
|
@@ -167,6 +199,28 @@ let BroadcastSetLevel = (_dec$1 = Broadcast({
|
|
|
167
199
|
}
|
|
168
200
|
}) || _class$1) || _class$1);
|
|
169
201
|
|
|
202
|
+
class Main extends BeanSimple {
|
|
203
|
+
async moduleLoading() {
|
|
204
|
+
// config
|
|
205
|
+
const _configDefault = await combineConfigDefault(this.app, configDefault);
|
|
206
|
+
this.app.config.logger = deepExtend({}, _configDefault, this.app.config.logger);
|
|
207
|
+
}
|
|
208
|
+
async moduleLoaded() {}
|
|
209
|
+
async configLoaded(_config) {}
|
|
210
|
+
}
|
|
211
|
+
async function configDefault(_app) {
|
|
212
|
+
return {
|
|
213
|
+
clients: {
|
|
214
|
+
default(clientInfo) {
|
|
215
|
+
const transports = [this.bean.logger.makeTransportFile(clientInfo, 'error', 'error'), this.bean.logger.makeTransportFile(clientInfo, 'warn', 'warn'), this.bean.logger.makeTransportFile(clientInfo, 'http', 'http'), this.bean.logger.makeTransportFile(clientInfo, 'combined'), this.bean.logger.makeTransportConsole(clientInfo)].filter(item => !!item);
|
|
216
|
+
return {
|
|
217
|
+
transports
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
170
224
|
var _dec, _dec2, _class;
|
|
171
225
|
let ScopeModuleALogger = (_dec = Scope(), _dec2 = BeanInfo({
|
|
172
226
|
module: "a-logger"
|
|
@@ -174,4 +228,4 @@ let ScopeModuleALogger = (_dec = Scope(), _dec2 = BeanInfo({
|
|
|
174
228
|
|
|
175
229
|
/** scope: end */
|
|
176
230
|
|
|
177
|
-
export { AopMethodLog, BeanLogger, BroadcastSetLevel, MiddlewareSystemHttpLog, ScopeModuleALogger };
|
|
231
|
+
export { AopMethodLog, BeanLogger, BroadcastSetLevel, Main, MiddlewareSystemHttpLog, ScopeModuleALogger, configDefault };
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ConfigLogger, IModuleMain, PowerPartial, VonaApplication } from 'vona';
|
|
2
|
+
import { BeanSimple } from 'vona';
|
|
3
|
+
export declare class Main extends BeanSimple implements IModuleMain {
|
|
4
|
+
moduleLoading(): Promise<void>;
|
|
5
|
+
moduleLoaded(): Promise<void>;
|
|
6
|
+
configLoaded(_config: any): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare function configDefault(_app: VonaApplication): Promise<PowerPartial<ConfigLogger>>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-a-logger",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.25",
|
|
5
5
|
"title": "a-logger",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"dependencies": {}
|
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
"static"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"pino-std-serializers": "^7.0.0"
|
|
29
|
+
"pino-std-serializers": "^7.0.0",
|
|
30
|
+
"winston": "^3.18.3",
|
|
31
|
+
"winston-transport": "^4.9.0"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
34
|
"clean-package": "^2.2.0",
|