vona-core 5.0.81 → 5.0.82
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { replaceTemplate } from '@cabloy/utils';
|
|
2
|
-
import { formatLoggerAxiosError } from "./utils.js";
|
|
2
|
+
import { formatLoggerAxiosError, formatLoggerCtx } from "./utils.js";
|
|
3
3
|
export function combineLoggerDefault(_appInfo, env) {
|
|
4
4
|
const configDefault = {
|
|
5
5
|
rotate: {
|
|
@@ -15,7 +15,7 @@ export function combineLoggerDefault(_appInfo, env) {
|
|
|
15
15
|
},
|
|
16
16
|
default(_clientInfo, { format }) {
|
|
17
17
|
return {
|
|
18
|
-
format: format.combine(formatLoggerAxiosError({ stack: true }), format.errors({ stack: true }), format.splat(), format.timestamp()),
|
|
18
|
+
format: format.combine(formatLoggerAxiosError({ stack: true }), formatLoggerCtx(), format.errors({ stack: true }), format.splat(), format.timestamp()),
|
|
19
19
|
transports: undefined,
|
|
20
20
|
};
|
|
21
21
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Winston from 'winston';
|
|
2
2
|
export declare const formatLoggerAxiosError: Winston.Logform.FormatWrap;
|
|
3
|
+
export declare const formatLoggerCtx: Winston.Logform.FormatWrap;
|
|
3
4
|
export declare const formatLoggerFilter: Winston.Logform.FormatWrap;
|
|
4
5
|
export declare const formatLoggerConsole: () => Winston.Logform.Format;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isEmptyObject } from '@cabloy/utils';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { LEVEL, MESSAGE } from 'triple-beam';
|
|
4
|
+
import { useApp } from 'vona';
|
|
4
5
|
import * as Winston from 'winston';
|
|
5
6
|
import { cast } from "../../../types/utils/cast.js";
|
|
6
7
|
const SymbolLoggerMessage = Symbol('SymbolLoggerMessage');
|
|
@@ -25,6 +26,14 @@ export const formatLoggerAxiosError = Winston.format((einfo, { stack, cause }) =
|
|
|
25
26
|
}
|
|
26
27
|
return einfo;
|
|
27
28
|
});
|
|
29
|
+
export const formatLoggerCtx = Winston.format((info, _opts) => {
|
|
30
|
+
const app = useApp();
|
|
31
|
+
if (!app.ctx || !app.ctx.method || !app.ctx.path)
|
|
32
|
+
return info;
|
|
33
|
+
info.method = app.ctx.method;
|
|
34
|
+
info.path = app.ctx.path;
|
|
35
|
+
return info;
|
|
36
|
+
});
|
|
28
37
|
export const formatLoggerFilter = Winston.format((info, opts) => {
|
|
29
38
|
const level = typeof opts.level === 'function' ? opts.level() : opts.level;
|
|
30
39
|
if (!level)
|