@nexe/logger 0.1.0
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/LICENSE +21 -0
- package/README.md +305 -0
- package/dist/config.d.ts +30 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +82 -0
- package/dist/config.js.map +1 -0
- package/dist/factory.d.ts +14 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +99 -0
- package/dist/factory.js.map +1 -0
- package/dist/formatters.d.ts +43 -0
- package/dist/formatters.d.ts.map +1 -0
- package/dist/formatters.js +110 -0
- package/dist/formatters.js.map +1 -0
- package/dist/global.d.ts +33 -0
- package/dist/global.d.ts.map +1 -0
- package/dist/global.js +130 -0
- package/dist/global.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +77 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +131 -0
- package/dist/logger.js.map +1 -0
- package/dist/serializers.d.ts +35 -0
- package/dist/serializers.d.ts.map +1 -0
- package/dist/serializers.js +151 -0
- package/dist/serializers.js.map +1 -0
- package/dist/test-error-logging.d.ts +3 -0
- package/dist/test-error-logging.d.ts.map +1 -0
- package/dist/test-error-logging.js +44 -0
- package/dist/test-error-logging.js.map +1 -0
- package/dist/transports.d.ts +56 -0
- package/dist/transports.d.ts.map +1 -0
- package/dist/transports.js +130 -0
- package/dist/transports.js.map +1 -0
- package/dist/types.d.ts +135 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/package.json +56 -0
@@ -0,0 +1,151 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
exports.querySerializer = exports.userSerializer = exports.responseSerializer = exports.requestSerializer = exports.errorSerializer = void 0;
|
37
|
+
exports.getDefaultSerializers = getDefaultSerializers;
|
38
|
+
exports.createSerializer = createSerializer;
|
39
|
+
const stdSerializers = __importStar(require("pino-std-serializers"));
|
40
|
+
/**
|
41
|
+
* 错误序列化器 - 扩展标准错误序列化器
|
42
|
+
*/
|
43
|
+
const errorSerializer = (err) => {
|
44
|
+
const serialized = stdSerializers.err(err);
|
45
|
+
return {
|
46
|
+
...serialized,
|
47
|
+
// 添加额外的错误信息
|
48
|
+
name: err.name,
|
49
|
+
message: err.message,
|
50
|
+
stack: err.stack,
|
51
|
+
// 如果是 HTTP 错误,添加状态码
|
52
|
+
...(err.status && { status: err.status }),
|
53
|
+
...(err.statusCode && { statusCode: err.statusCode }),
|
54
|
+
};
|
55
|
+
};
|
56
|
+
exports.errorSerializer = errorSerializer;
|
57
|
+
/**
|
58
|
+
* 请求序列化器
|
59
|
+
*/
|
60
|
+
const requestSerializer = (req) => {
|
61
|
+
if (!req)
|
62
|
+
return req;
|
63
|
+
return {
|
64
|
+
id: req.id,
|
65
|
+
method: req.method,
|
66
|
+
url: req.url,
|
67
|
+
path: req.path,
|
68
|
+
parameters: req.parameters,
|
69
|
+
query: req.query,
|
70
|
+
headers: {
|
71
|
+
// 只记录重要的头部信息,避免敏感信息泄露
|
72
|
+
"content-type": req.headers?.["content-type"],
|
73
|
+
"user-agent": req.headers?.["user-agent"],
|
74
|
+
accept: req.headers?.["accept"],
|
75
|
+
"accept-encoding": req.headers?.["accept-encoding"],
|
76
|
+
"accept-language": req.headers?.["accept-language"],
|
77
|
+
},
|
78
|
+
remoteAddress: req.socket?.remoteAddress,
|
79
|
+
remotePort: req.socket?.remotePort,
|
80
|
+
};
|
81
|
+
};
|
82
|
+
exports.requestSerializer = requestSerializer;
|
83
|
+
/**
|
84
|
+
* 响应序列化器
|
85
|
+
*/
|
86
|
+
const responseSerializer = (res) => {
|
87
|
+
if (!res)
|
88
|
+
return res;
|
89
|
+
return {
|
90
|
+
statusCode: res.statusCode,
|
91
|
+
headers: {
|
92
|
+
"content-type": res.getHeader?.("content-type"),
|
93
|
+
"content-length": res.getHeader?.("content-length"),
|
94
|
+
},
|
95
|
+
};
|
96
|
+
};
|
97
|
+
exports.responseSerializer = responseSerializer;
|
98
|
+
/**
|
99
|
+
* 用户序列化器 - 避免敏感信息泄露
|
100
|
+
*/
|
101
|
+
const userSerializer = (user) => {
|
102
|
+
if (!user)
|
103
|
+
return user;
|
104
|
+
const { password, token, secret, ...safeUser } = user;
|
105
|
+
return safeUser;
|
106
|
+
};
|
107
|
+
exports.userSerializer = userSerializer;
|
108
|
+
/**
|
109
|
+
* 数据库查询序列化器
|
110
|
+
*/
|
111
|
+
const querySerializer = (query) => {
|
112
|
+
if (!query)
|
113
|
+
return query;
|
114
|
+
return {
|
115
|
+
sql: query.sql,
|
116
|
+
duration: query.duration,
|
117
|
+
rowCount: query.rowCount,
|
118
|
+
// 不记录参数值,避免敏感数据泄露
|
119
|
+
hasParameters: Array.isArray(query.parameters) && query.parameters.length > 0,
|
120
|
+
};
|
121
|
+
};
|
122
|
+
exports.querySerializer = querySerializer;
|
123
|
+
/**
|
124
|
+
* 获取默认序列化器
|
125
|
+
*/
|
126
|
+
function getDefaultSerializers() {
|
127
|
+
return {
|
128
|
+
// 使用 pino 标准的序列化器
|
129
|
+
req: stdSerializers.req,
|
130
|
+
res: stdSerializers.res,
|
131
|
+
// 不使用任何错误序列化器,让pino使用默认处理
|
132
|
+
// 自定义序列化器
|
133
|
+
user: exports.userSerializer,
|
134
|
+
query: exports.querySerializer,
|
135
|
+
};
|
136
|
+
}
|
137
|
+
/**
|
138
|
+
* 创建自定义序列化器
|
139
|
+
*/
|
140
|
+
function createSerializer(fn) {
|
141
|
+
return (value) => {
|
142
|
+
try {
|
143
|
+
return fn(value);
|
144
|
+
}
|
145
|
+
catch (error) {
|
146
|
+
// 如果序列化失败,返回安全的字符串表示
|
147
|
+
return `[Serialization Error: ${error instanceof Error ? error.message : "Unknown"}]`;
|
148
|
+
}
|
149
|
+
};
|
150
|
+
}
|
151
|
+
//# sourceMappingURL=serializers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"serializers.js","sourceRoot":"","sources":["../src/serializers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFA,sDAUC;AAKD,4CAWC;AAnHD,qEAAuD;AAEvD;;GAEG;AACI,MAAM,eAAe,GAAG,CAAC,GAAU,EAAE,EA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GAAG;QACvB,GAAG,EAAE,cAAc,CAAC,GAAG;QACvB,0BAA0B;QAC1B,UAAU;QACV,IAAI,EAAE,sBAAc;QACpB,KAAK,EAAE,uBAAe;KACvB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,EAAqB;IAErB,OAAO,CAAC,KAAQ,EAAE,EAAE;QAClB,IAAI,CAAC;YACH,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qBAAqB;YACrB,OAAO,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC;QACxF,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"test-error-logging.d.ts","sourceRoot":"","sources":["../src/test-error-logging.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env bun
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
const factory_1 = require("./factory");
|
5
|
+
// 创建测试 logger
|
6
|
+
const logger = (0, factory_1.createLogger)('ErrorTest');
|
7
|
+
// 创建一些测试错误
|
8
|
+
const simpleError = new Error('This is a simple error');
|
9
|
+
const complexError = new Error('Complex error with custom properties');
|
10
|
+
complexError.statusCode = 500;
|
11
|
+
complexError.code = 'INTERNAL_ERROR';
|
12
|
+
console.log('=== Testing Enhanced Error Logging ===\n');
|
13
|
+
// 测试 1: 直接传递错误消息和错误对象
|
14
|
+
console.log('Test 1: logger.error("报错了", error)');
|
15
|
+
logger.error('报错了', simpleError);
|
16
|
+
console.log('\nTest 2: logger.error("报错了", complexError)');
|
17
|
+
logger.error('报错了', complexError);
|
18
|
+
// 测试 3: 错误对象在前,消息在后
|
19
|
+
console.log('\nTest 3: logger.error(error, "发生了错误")');
|
20
|
+
logger.error(simpleError, '发生了错误');
|
21
|
+
// 测试 4: 只传递错误对象
|
22
|
+
console.log('\nTest 4: logger.error(error)');
|
23
|
+
logger.error(complexError);
|
24
|
+
// 测试 5: 错误与额外数据
|
25
|
+
console.log('\nTest 5: logger.error("API调用失败", error, { userId: 123, endpoint: "/api/users" })');
|
26
|
+
logger.error('API调用失败', simpleError, { userId: 123, endpoint: '/api/users' });
|
27
|
+
// 测试 6: 多个错误
|
28
|
+
console.log('\nTest 6: logger.error("多重错误", error1, error2)');
|
29
|
+
logger.error('多重错误', simpleError, complexError);
|
30
|
+
// 测试 7: 传统方式对比
|
31
|
+
console.log('\nTest 7: 传统方式 (应该仍然工作)');
|
32
|
+
logger.error({ err: simpleError }, '传统方式记录错误');
|
33
|
+
// 测试 8: 复杂场景
|
34
|
+
console.log('\nTest 8: 复杂场景');
|
35
|
+
const requestError = new Error('Request timeout');
|
36
|
+
requestError.timeout = 5000;
|
37
|
+
requestError.url = 'https://api.example.com';
|
38
|
+
logger.error('请求超时', requestError, {
|
39
|
+
requestId: 'req-123',
|
40
|
+
retry: 3,
|
41
|
+
metadata: { source: 'api-client' }
|
42
|
+
});
|
43
|
+
console.log('\n=== Error Logging Tests Complete ===');
|
44
|
+
//# sourceMappingURL=test-error-logging.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"test-error-logging.js","sourceRoot":"","sources":["../src/test-error-logging.ts"],"names":[],"mappings":";;;AAEA,uCAAyC;AAEzC,cAAc;AACd,MAAM,MAAM,GAAG,IAAA,sBAAY,EAAC,WAAW,CAAC,CAAC;AAEzC,WAAW;AACX,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;AACxD,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;AACtE,YAAoB,CAAC,UAAU,GAAG,GAAG,CAAC;AACtC,YAAoB,CAAC,IAAI,GAAG,gBAAgB,CAAC;AAE9C,OAAO,CAAC,G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,EAAE,YAAY,EAAE;IACjC,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE;CACnC,CAAC,CAAC;AAEH,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC"}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import type { TransportConfig } from "./types";
|
2
|
+
/**
|
3
|
+
* 控制台传输配置
|
4
|
+
*/
|
5
|
+
export declare function createConsoleTransport(options?: {
|
6
|
+
colorize?: boolean;
|
7
|
+
translateTime?: boolean | string;
|
8
|
+
ignore?: string;
|
9
|
+
singleLine?: boolean;
|
10
|
+
hideObject?: boolean;
|
11
|
+
}): TransportConfig;
|
12
|
+
/**
|
13
|
+
* 文件传输配置
|
14
|
+
*/
|
15
|
+
export declare function createFileTransport(options?: {
|
16
|
+
destination: string;
|
17
|
+
mkdir?: boolean;
|
18
|
+
append?: boolean;
|
19
|
+
maxSize?: number;
|
20
|
+
maxFiles?: number;
|
21
|
+
}): TransportConfig;
|
22
|
+
/**
|
23
|
+
* 滚动文件传输配置
|
24
|
+
*/
|
25
|
+
export declare function createRotatingFileTransport(options?: {
|
26
|
+
filename: string;
|
27
|
+
frequency?: string;
|
28
|
+
maxSize?: string;
|
29
|
+
maxFiles?: string | number;
|
30
|
+
dateFormat?: string;
|
31
|
+
}): TransportConfig;
|
32
|
+
/**
|
33
|
+
* JSON 文件传输配置
|
34
|
+
*/
|
35
|
+
export declare function createJsonFileTransport(options?: {
|
36
|
+
destination: string;
|
37
|
+
mkdir?: boolean;
|
38
|
+
append?: boolean;
|
39
|
+
}): TransportConfig;
|
40
|
+
/**
|
41
|
+
* 多传输配置
|
42
|
+
*/
|
43
|
+
export declare function createMultiTransport(transports: TransportConfig[]): any;
|
44
|
+
/**
|
45
|
+
* 开发环境传输
|
46
|
+
*/
|
47
|
+
export declare function createDevelopmentTransport(): TransportConfig;
|
48
|
+
/**
|
49
|
+
* 生产环境传输
|
50
|
+
*/
|
51
|
+
export declare function createProductionTransport(): any;
|
52
|
+
/**
|
53
|
+
* 根据环境获取传输配置
|
54
|
+
*/
|
55
|
+
export declare function getEnvironmentTransport(env?: string): any;
|
56
|
+
//# sourceMappingURL=transports.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transports.d.ts","sourceRoot":"","sources":["../src/transports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,GAAE;IACP,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACjB,GACL,eAAe,CAcjB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE;IACP,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACiB,GACpC,eAAe,CAYjB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,GAAE;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACmB,GACxC,eAAe,CAajB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,GAAE;IACP,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CACmB,GACrC,eAAe,CAUjB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,eAAe,EAAE,GAAG,GAAG,CAQvE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,eAAe,CAO5D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,GAAG,CAS/C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAezD"}
|
@@ -0,0 +1,130 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createConsoleTransport = createConsoleTransport;
|
4
|
+
exports.createFileTransport = createFileTransport;
|
5
|
+
exports.createRotatingFileTransport = createRotatingFileTransport;
|
6
|
+
exports.createJsonFileTransport = createJsonFileTransport;
|
7
|
+
exports.createMultiTransport = createMultiTransport;
|
8
|
+
exports.createDevelopmentTransport = createDevelopmentTransport;
|
9
|
+
exports.createProductionTransport = createProductionTransport;
|
10
|
+
exports.getEnvironmentTransport = getEnvironmentTransport;
|
11
|
+
/**
|
12
|
+
* 控制台传输配置
|
13
|
+
*/
|
14
|
+
function createConsoleTransport(options = {}) {
|
15
|
+
return {
|
16
|
+
type: "console",
|
17
|
+
target: "pino-pretty",
|
18
|
+
options: {
|
19
|
+
colorize: options.colorize ?? true,
|
20
|
+
translateTime: options.translateTime ?? "yyyy-mm-dd HH:MM:ss.l",
|
21
|
+
ignore: options.ignore ?? "pid,hostname",
|
22
|
+
singleLine: options.singleLine ?? false,
|
23
|
+
hideObject: options.hideObject ?? false,
|
24
|
+
messageFormat: "{end}{msg}",
|
25
|
+
...options,
|
26
|
+
},
|
27
|
+
};
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* 文件传输配置
|
31
|
+
*/
|
32
|
+
function createFileTransport(options = { destination: "./logs/app.log" }) {
|
33
|
+
const { destination, ...restOptions } = options;
|
34
|
+
return {
|
35
|
+
type: "file",
|
36
|
+
target: "pino/file",
|
37
|
+
options: {
|
38
|
+
destination,
|
39
|
+
mkdir: true,
|
40
|
+
append: true,
|
41
|
+
...restOptions,
|
42
|
+
},
|
43
|
+
};
|
44
|
+
}
|
45
|
+
/**
|
46
|
+
* 滚动文件传输配置
|
47
|
+
*/
|
48
|
+
function createRotatingFileTransport(options = { filename: "./logs/app-%DATE%.log" }) {
|
49
|
+
return {
|
50
|
+
type: "custom",
|
51
|
+
target: "pino-roll",
|
52
|
+
options: {
|
53
|
+
file: options.filename,
|
54
|
+
frequency: options.frequency ?? "daily",
|
55
|
+
size: options.maxSize ?? "10M",
|
56
|
+
limit: options.maxFiles ?? "7",
|
57
|
+
dateFormat: options.dateFormat ?? "YYYY-MM-DD",
|
58
|
+
...options,
|
59
|
+
},
|
60
|
+
};
|
61
|
+
}
|
62
|
+
/**
|
63
|
+
* JSON 文件传输配置
|
64
|
+
*/
|
65
|
+
function createJsonFileTransport(options = { destination: "./logs/app.json" }) {
|
66
|
+
return {
|
67
|
+
type: "file",
|
68
|
+
target: "pino/file",
|
69
|
+
options: {
|
70
|
+
destination: options.destination,
|
71
|
+
mkdir: options.mkdir ?? true,
|
72
|
+
append: options.append ?? true,
|
73
|
+
},
|
74
|
+
};
|
75
|
+
}
|
76
|
+
/**
|
77
|
+
* 多传输配置
|
78
|
+
*/
|
79
|
+
function createMultiTransport(transports) {
|
80
|
+
return {
|
81
|
+
targets: transports.map((transport) => ({
|
82
|
+
target: transport.target,
|
83
|
+
options: transport.options,
|
84
|
+
level: transport.options?.level,
|
85
|
+
})),
|
86
|
+
};
|
87
|
+
}
|
88
|
+
/**
|
89
|
+
* 开发环境传输
|
90
|
+
*/
|
91
|
+
function createDevelopmentTransport() {
|
92
|
+
return createConsoleTransport({
|
93
|
+
colorize: true,
|
94
|
+
translateTime: "yy-mm-dd HH:MM:ss.l",
|
95
|
+
ignore: "pid,hostname",
|
96
|
+
singleLine: false,
|
97
|
+
});
|
98
|
+
}
|
99
|
+
/**
|
100
|
+
* 生产环境传输
|
101
|
+
*/
|
102
|
+
function createProductionTransport() {
|
103
|
+
return createMultiTransport([
|
104
|
+
createJsonFileTransport({
|
105
|
+
destination: "./logs/app.json",
|
106
|
+
}),
|
107
|
+
createFileTransport({
|
108
|
+
destination: "./logs/error.log",
|
109
|
+
}),
|
110
|
+
]);
|
111
|
+
}
|
112
|
+
/**
|
113
|
+
* 根据环境获取传输配置
|
114
|
+
*/
|
115
|
+
function getEnvironmentTransport(env) {
|
116
|
+
const environment = env || process.env.NODE_ENV || "development";
|
117
|
+
switch (environment) {
|
118
|
+
case "production":
|
119
|
+
case "prod":
|
120
|
+
return createProductionTransport();
|
121
|
+
case "test":
|
122
|
+
case "testing":
|
123
|
+
return undefined; // 测试环境通常不需要传输
|
124
|
+
case "development":
|
125
|
+
case "dev":
|
126
|
+
default:
|
127
|
+
return createDevelopmentTransport();
|
128
|
+
}
|
129
|
+
}
|
130
|
+
//# sourceMappingURL=transports.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transports.js","sourceRoot":"","sources":["../src/transports.ts"],"names":[],"mappings":";;AAKA,wDAsBC;AAKD,kDAoBC;AAKD,kEAqBC;AAKD,0DAgBC;AAKD,oDAQC;AAKD,gEAOC;AAKD,8DASC;AAKD,0DAeC;AA5JD;;GAEG;AACH,SAAgB,sBAAsB,CACpC,UAMI,EAAE;IAEN,OAAO;QACL,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE;YACP,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI;YAClC,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,uBAAuB;YAC/D,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,cAAc;YACxC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,KAAK;YACvC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,KAAK;YACvC,aAAa,EAAE,YAAY;YAC3B,GAAG,OAA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,CAAC;YACtC,MAAM,EAAE,SAAS,CAAC,MAAM;YACxB,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,KAAK;SAChC,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,0BAA0B;IACxC,OAAO,sBAAsB,CAAC;QAC5B,QAAQ,EAAE,IAAI;QACd,aAAa,EAAE,qBAAqB;QACpC,MAAM,EAAE,cAAc;QACtB,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB;IACvC,OAAO,oBAAoB,CAAC;QAC1B,uBAAuB,CAAC;YACtB,WAAW,EAAE,iBAAiB;SAC/B,CAAC;QACF,mBAAmB,CAAC;YAClB,WAAW,EAAE,kBAAkB;SAChC,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAgB,uBAAuB,CAAC,GAAY;IAClD,MAAM,WAAW,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;IAEjE,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,YAAY,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,yBAAyB,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC;QACZ,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC,CAAC,cAAc;QAClC,KAAK,aAAa,CAAC;QACnB,KAAK,KAAK,CAAC;QACX;YACE,OAAO,0BAA0B,EAAE,CAAC;IACxC,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
import type { Logger as PinoLogger } from 'pino';
|
2
|
+
/**
|
3
|
+
* 日志级别枚举
|
4
|
+
*/
|
5
|
+
export declare enum LogLevel {
|
6
|
+
FATAL = "fatal",
|
7
|
+
ERROR = "error",
|
8
|
+
WARN = "warn",
|
9
|
+
INFO = "info",
|
10
|
+
DEBUG = "debug",
|
11
|
+
TRACE = "trace"
|
12
|
+
}
|
13
|
+
/**
|
14
|
+
* 日志配置接口
|
15
|
+
*/
|
16
|
+
export interface LoggerConfig {
|
17
|
+
/** 日志级别 */
|
18
|
+
level?: LogLevel | string;
|
19
|
+
/** 日志名称 */
|
20
|
+
name?: string;
|
21
|
+
/** 是否启用时间戳 */
|
22
|
+
timestamp?: boolean;
|
23
|
+
/** 序列化器配置 */
|
24
|
+
serializers?: Record<string, (value: any) => any>;
|
25
|
+
/** 自定义格式化器 */
|
26
|
+
formatters?: {
|
27
|
+
level?: (label: string, number: number) => object;
|
28
|
+
bindings?: (bindings: Record<string, any>) => Record<string, any>;
|
29
|
+
log?: (object: Record<string, any>) => Record<string, any>;
|
30
|
+
};
|
31
|
+
/** 传输配置 */
|
32
|
+
transport?: any;
|
33
|
+
/** 重新定义配置 */
|
34
|
+
redact?: string[] | {
|
35
|
+
paths: string[];
|
36
|
+
censor?: string;
|
37
|
+
};
|
38
|
+
/** 基础配置 */
|
39
|
+
base?: Record<string, any> | null;
|
40
|
+
/** 钩子函数 */
|
41
|
+
hooks?: {
|
42
|
+
logMethod?: (inputArgs: any[], method: any, level: number) => void;
|
43
|
+
};
|
44
|
+
/** 自定义错误序列化器 */
|
45
|
+
customLevels?: Record<string, number>;
|
46
|
+
/** 使用仅级别标签 */
|
47
|
+
useOnlyCustomLevels?: boolean;
|
48
|
+
/** 混合函数 */
|
49
|
+
mixin?: () => Record<string, any>;
|
50
|
+
/** 消息键 */
|
51
|
+
messageKey?: string;
|
52
|
+
/** 错误键 */
|
53
|
+
errorKey?: string;
|
54
|
+
/** 换行符 */
|
55
|
+
nestedKey?: string;
|
56
|
+
}
|
57
|
+
/**
|
58
|
+
* 日志上下文接口
|
59
|
+
*/
|
60
|
+
export interface LogContext {
|
61
|
+
/** 请求ID */
|
62
|
+
requestId?: string;
|
63
|
+
/** 用户ID */
|
64
|
+
userId?: string;
|
65
|
+
/** 跟踪ID */
|
66
|
+
traceId?: string;
|
67
|
+
/** 额外的上下文数据 */
|
68
|
+
[key: string]: any;
|
69
|
+
}
|
70
|
+
/**
|
71
|
+
* HestJS Logger 接口
|
72
|
+
*/
|
73
|
+
export interface Logger {
|
74
|
+
/** 原始 Pino Logger 实例 */
|
75
|
+
readonly pino: PinoLogger;
|
76
|
+
/** 设置上下文 */
|
77
|
+
setContext(context: LogContext): Logger;
|
78
|
+
/** 获取子 Logger */
|
79
|
+
child(bindings: Record<string, any>): Logger;
|
80
|
+
/** Fatal 级别日志 */
|
81
|
+
fatal(message: string, error: Error, ...args: any[]): void;
|
82
|
+
fatal(error: Error, message?: string, ...args: any[]): void;
|
83
|
+
fatal(obj: object, message?: string, ...args: any[]): void;
|
84
|
+
fatal(message: string, ...args: any[]): void;
|
85
|
+
/** Error 级别日志 */
|
86
|
+
error(message: string, error: Error, ...args: any[]): void;
|
87
|
+
error(error: Error, message?: string, ...args: any[]): void;
|
88
|
+
error(obj: object, message?: string, ...args: any[]): void;
|
89
|
+
error(message: string, ...args: any[]): void;
|
90
|
+
/** Warn 级别日志 */
|
91
|
+
warn(message: string, error: Error, ...args: any[]): void;
|
92
|
+
warn(error: Error, message?: string, ...args: any[]): void;
|
93
|
+
warn(obj: object, message?: string, ...args: any[]): void;
|
94
|
+
warn(message: string, ...args: any[]): void;
|
95
|
+
/** Info 级别日志 */
|
96
|
+
info(message: string, error: Error, ...args: any[]): void;
|
97
|
+
info(error: Error, message?: string, ...args: any[]): void;
|
98
|
+
info(obj: object, message?: string, ...args: any[]): void;
|
99
|
+
info(message: string, ...args: any[]): void;
|
100
|
+
/** Debug 级别日志 */
|
101
|
+
debug(message: string, error: Error, ...args: any[]): void;
|
102
|
+
debug(error: Error, message?: string, ...args: any[]): void;
|
103
|
+
debug(obj: object, message?: string, ...args: any[]): void;
|
104
|
+
debug(message: string, ...args: any[]): void;
|
105
|
+
/** Trace 级别日志 */
|
106
|
+
trace(message: string, error: Error, ...args: any[]): void;
|
107
|
+
trace(error: Error, message?: string, ...args: any[]): void;
|
108
|
+
trace(obj: object, message?: string, ...args: any[]): void;
|
109
|
+
trace(message: string, ...args: any[]): void;
|
110
|
+
/** 刷新日志 */
|
111
|
+
flush(): void;
|
112
|
+
/** 检查是否启用了指定级别 */
|
113
|
+
isLevelEnabled(level: LogLevel | string): boolean;
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* 传输类型
|
117
|
+
*/
|
118
|
+
export type TransportType = 'console' | 'file' | 'stream' | 'custom';
|
119
|
+
/**
|
120
|
+
* 传输配置
|
121
|
+
*/
|
122
|
+
export interface TransportConfig {
|
123
|
+
type: TransportType;
|
124
|
+
target?: string;
|
125
|
+
options?: Record<string, any>;
|
126
|
+
}
|
127
|
+
/**
|
128
|
+
* 环境变量
|
129
|
+
*/
|
130
|
+
export interface LoggerEnvironment {
|
131
|
+
NODE_ENV?: string;
|
132
|
+
LOG_LEVEL?: string;
|
133
|
+
LOG_NAME?: string;
|
134
|
+
}
|
135
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,MAAM,CAAC;AAEjD;;GAEG;AACH,oBAAY,QAAQ;IAClB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;IACf,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW;IACX,KAAK,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC1B,WAAW;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa;IACb,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,CAAC;IA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C,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
package/dist/types.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.LogLevel = void 0;
|
4
|
+
/**
|
5
|
+
* 日志级别枚举
|
6
|
+
*/
|
7
|
+
var LogLevel;
|
8
|
+
(function (LogLevel) {
|
9
|
+
LogLevel["FATAL"] = "fatal";
|
10
|
+
LogLevel["ERROR"] = "error";
|
11
|
+
LogLevel["WARN"] = "warn";
|
12
|
+
LogLevel["INFO"] = "info";
|
13
|
+
LogLevel["DEBUG"] = "debug";
|
14
|
+
LogLevel["TRACE"] = "trace";
|
15
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
16
|
+
//# sourceMappingURL=types.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB,2BAAe,CAAA;IACf,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;IACf,2BAAe,CAAA;AACjB,CAAC,EAPW,QAAQ,wBAAR,QAAQ,QAOnB"}
|
package/package.json
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
{
|
2
|
+
"name": "@nexe/logger",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"description": "Nexe Logger - A powerful logging solution based on Pino",
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"types": "dist/index.d.ts",
|
7
|
+
"files": [
|
8
|
+
"dist",
|
9
|
+
"README.md",
|
10
|
+
"LICENSE"
|
11
|
+
],
|
12
|
+
"scripts": {
|
13
|
+
"build": "tsc",
|
14
|
+
"dev": "tsc --watch",
|
15
|
+
"clean": "rm -rf dist",
|
16
|
+
"check-types": "tsc --noEmit",
|
17
|
+
"prepublishOnly": "npm run clean && npm run build",
|
18
|
+
"publish:npm": "npm publish --access public"
|
19
|
+
},
|
20
|
+
"repository": {
|
21
|
+
"type": "git",
|
22
|
+
"url": "https://github.com/aqz236/nexe-logger.git"
|
23
|
+
},
|
24
|
+
"homepage": "https://github.com/aqz236/nexe-logger#readme",
|
25
|
+
"bugs": {
|
26
|
+
"url": "https://github.com/aqz236/nexe-logger/issues"
|
27
|
+
},
|
28
|
+
"author": "aqz236",
|
29
|
+
"license": "MIT",
|
30
|
+
"dependencies": {
|
31
|
+
"pino": "^9.7.0",
|
32
|
+
"pino-pretty": "^13.1.1",
|
33
|
+
"pino-std-serializers": "^7.0.0"
|
34
|
+
},
|
35
|
+
"devDependencies": {
|
36
|
+
"@types/node": "^24.1.0",
|
37
|
+
"typescript": "5.8.3"
|
38
|
+
},
|
39
|
+
"peerDependencies": {
|
40
|
+
"typescript": ">=5.0.0"
|
41
|
+
},
|
42
|
+
"exports": {
|
43
|
+
".": {
|
44
|
+
"import": "./dist/index.js",
|
45
|
+
"require": "./dist/index.js",
|
46
|
+
"types": "./dist/index.d.ts"
|
47
|
+
}
|
48
|
+
},
|
49
|
+
"keywords": [
|
50
|
+
"hestjs",
|
51
|
+
"logger",
|
52
|
+
"pino",
|
53
|
+
"logging",
|
54
|
+
"structured-logging"
|
55
|
+
]
|
56
|
+
}
|