skyeye-svc-common-utils 2.0.0-dev0.32 → 2.0.0-dev0.34
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,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
export declare const morganFile: (req: IncomingMessage, res: ServerResponse<IncomingMessage>, callback: (err?: Error) => void) => void;
|
|
4
|
+
export declare const morganConsole: (req: IncomingMessage, res: ServerResponse<IncomingMessage>, callback: (err?: Error) => void) => void;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.morganConsole = exports.morganFile = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const morgan_1 = __importDefault(require("morgan"));
|
|
9
|
-
const rotating_file_stream_1 =
|
|
9
|
+
const rotating_file_stream_1 = require("rotating-file-stream");
|
|
10
10
|
const appConfig_1 = require("../appConfig");
|
|
11
11
|
const dateformat_1 = __importDefault(require("dateformat"));
|
|
12
12
|
// ensure log directory exists
|
|
@@ -19,7 +19,7 @@ const FileNameGenerator = (time, index) => {
|
|
|
19
19
|
return `backend-access-${(0, dateformat_1.default)(time, 'yyyy-mm-dd')}${indexStr}.log`;
|
|
20
20
|
};
|
|
21
21
|
// create a rotating write stream
|
|
22
|
-
const accessLogStream = rotating_file_stream_1.
|
|
22
|
+
const accessLogStream = (0, rotating_file_stream_1.createStream)(FileNameGenerator, {
|
|
23
23
|
interval: '1d',
|
|
24
24
|
path: appConfig_1.commonAppConfig.LogPath
|
|
25
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"morganLogger.js","sourceRoot":"","sources":["../../../src/utils/logger/morganLogger.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,
|
|
1
|
+
{"version":3,"file":"morganLogger.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AC,eAAe,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI;QACxD,WAAW,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI;QAClD,aAAa,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;QAC/C,SAAS,EAAE,2BAAe,CAAC,OAAO;KACnC,CAAC,CAAA;AACR,CAAC,CAAA;AAED,mBAAmB;AACN,QAAA,UAAU,GAAG,IAAA,gBAAM,EAAC,UAAU,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;AAE7D,QAAA,aAAa,GAAG,IAAA,gBAAM,EAAC,UAAU,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skyeye-svc-common-utils",
|
|
3
|
-
"version": "2.0.0-dev0.
|
|
3
|
+
"version": "2.0.0-dev0.34",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"node-fetch": "^2.6.0",
|
|
45
45
|
"rotating-file-stream": "^3.2.1",
|
|
46
46
|
"skyeye-common-const": "1.0.42",
|
|
47
|
-
"swagger-jsdoc": "^
|
|
47
|
+
"swagger-jsdoc": "^6.2.8",
|
|
48
48
|
"typeorm": "^0.3.17",
|
|
49
49
|
"winston": "^3.2.1",
|
|
50
50
|
"winston-daily-rotate-file": "^4.2.1",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import morgan from 'morgan';
|
|
3
|
-
import
|
|
2
|
+
import morgan, { TokenIndexer } from 'morgan';
|
|
3
|
+
import { createStream } from 'rotating-file-stream';
|
|
4
4
|
import { commonAppConfig } from '../appConfig';
|
|
5
5
|
import dateformat from 'dateformat';
|
|
6
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
6
7
|
|
|
7
8
|
// ensure log directory exists
|
|
8
9
|
fs.existsSync(commonAppConfig.LogPath) || fs.mkdirSync(commonAppConfig.LogPath);
|
|
@@ -17,12 +18,12 @@ const FileNameGenerator = (time: number | Date, index: number) => {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
// create a rotating write stream
|
|
20
|
-
const accessLogStream =
|
|
21
|
+
const accessLogStream = createStream(FileNameGenerator, {
|
|
21
22
|
interval: '1d', // rotate daily
|
|
22
23
|
path: commonAppConfig.LogPath
|
|
23
24
|
});
|
|
24
25
|
|
|
25
|
-
const jsonFormat = (tokens:
|
|
26
|
+
const jsonFormat = (tokens: TokenIndexer, req: IncomingMessage, res: ServerResponse) => {
|
|
26
27
|
return JSON.stringify({
|
|
27
28
|
"method": tokens.method(req, res),
|
|
28
29
|
"url": tokens.url(req, res),
|
|
@@ -38,4 +39,4 @@ const jsonFormat = (tokens: any, req: any, res: any) => {
|
|
|
38
39
|
// setup the logger
|
|
39
40
|
export const morganFile = morgan(jsonFormat, { stream: accessLogStream });
|
|
40
41
|
|
|
41
|
-
export const morganConsole =
|
|
42
|
+
export const morganConsole = morgan(jsonFormat);
|