@yozu-libs/logger 1.0.0-alpha.8
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/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/package.json +31 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as winston from 'winston';
|
|
2
|
+
export declare const logger: winston.Logger;
|
|
3
|
+
export declare const YozuLogger: (context: string) => {
|
|
4
|
+
info: (msg: string, meta?: any) => winston.Logger;
|
|
5
|
+
error: (msg: string, trace?: string, meta?: any) => winston.Logger;
|
|
6
|
+
debug: (msg: string, meta?: any) => winston.Logger;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAQnC,eAAO,MAAM,MAAM,gBAajB,CAAC;AAGH,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM;gBAE1B,MAAM,SAAS,GAAG;iBACjB,MAAM,UAAU,MAAM,SAAS,GAAG;iBAClC,MAAM,SAAS,GAAG;CAElC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
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.YozuLogger = exports.logger = void 0;
|
|
37
|
+
const winston = __importStar(require("winston"));
|
|
38
|
+
const customFormat = winston.format.printf(({ level, message, timestamp, context, ...meta }) => {
|
|
39
|
+
return `${timestamp} [${level.toUpperCase()}]${context ? ` [${context}]` : ''}: ${message} ${Object.keys(meta).length ? JSON.stringify(meta) : ''}`;
|
|
40
|
+
});
|
|
41
|
+
exports.logger = winston.createLogger({
|
|
42
|
+
level: process.env.NODE_ENV === 'production' ? 'info' : 'debug',
|
|
43
|
+
format: winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.errors({ stack: true }), winston.format.splat(), process.env.NODE_ENV !== 'production'
|
|
44
|
+
? winston.format.combine(winston.format.colorize(), customFormat)
|
|
45
|
+
: winston.format.json()),
|
|
46
|
+
transports: [
|
|
47
|
+
new winston.transports.Console(),
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
const YozuLogger = (context) => {
|
|
51
|
+
return {
|
|
52
|
+
info: (msg, meta) => exports.logger.info(msg, { context, ...meta }),
|
|
53
|
+
error: (msg, trace, meta) => exports.logger.error(msg, { context, trace, ...meta }),
|
|
54
|
+
debug: (msg, meta) => exports.logger.debug(msg, { context, ...meta }),
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
exports.YozuLogger = YozuLogger;
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAEnC,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE;IAC7F,OAAO,GAAG,SAAS,KAAK,KAAK,CAAC,WAAW,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,IACvF,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EACpD,EAAE,CAAC;AACL,CAAC,CAAC,CAAC;AAEU,QAAA,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IACzC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;IAC/D,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,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
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsc -w",
|
|
14
|
+
"clean": "rm -rf dist"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"winston": "^3.19.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.9.3"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"registry": "https://registry.npmjs.org/"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/VictorAgahi/yozu-libs.git",
|
|
29
|
+
"directory": "packages/logger"
|
|
30
|
+
}
|
|
31
|
+
}
|