typeshi 1.1.0 → 1.2.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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @file src/config/setupLog.ts
|
|
3
3
|
* @reference https://tslog.js.org/#/?id=pretty-templates-and-styles-color-settings
|
|
4
4
|
*/
|
|
5
|
-
import { Logger, ILogObj
|
|
5
|
+
import { Logger, ILogObj } from 'tslog';
|
|
6
6
|
/**
|
|
7
7
|
* `TAB = INDENT_LOG_LINE = '\n\t• '` = newLine + tab + bullet + space
|
|
8
8
|
* - log.debug(s1, INDENT_LOG_LINE + s2, INDENT_LOG_LINE + s3,...)
|
|
@@ -28,9 +28,3 @@ export declare const NEW_LINE: string;
|
|
|
28
28
|
export declare const typeshiLogger: Logger<ILogObj>;
|
|
29
29
|
export declare const typeshiSimpleLogger: Logger<ILogObj>;
|
|
30
30
|
export declare const typeshiHiddenLogger: Logger<ILogObj>;
|
|
31
|
-
/**
|
|
32
|
-
* reduce metadata into `logObj['-1']` then return stringified `logObj`
|
|
33
|
-
* @param logObj {@link ILogObj}
|
|
34
|
-
* @returns `string`
|
|
35
|
-
*/
|
|
36
|
-
export declare function formatLogObj(logObj: ILogObj | (ILogObj & ILogObjMeta)): string;
|
package/dist/config/setupLog.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.typeshiHiddenLogger = exports.typeshiSimpleLogger = exports.typeshiLogger = exports.NEW_LINE = exports.INDENT_LOG_LINE = void 0;
|
|
4
|
-
exports.formatLogObj = formatLogObj;
|
|
5
4
|
/**
|
|
6
5
|
* @file src/config/setupLog.ts
|
|
7
6
|
* @reference https://tslog.js.org/#/?id=pretty-templates-and-styles-color-settings
|
|
@@ -134,19 +133,3 @@ const HIDDEN_LOGGER_SETTINGS = {
|
|
|
134
133
|
prettyLogStyles: PRETTY_LOG_STYLES,
|
|
135
134
|
};
|
|
136
135
|
exports.typeshiHiddenLogger = new tslog_1.Logger(HIDDEN_LOGGER_SETTINGS);
|
|
137
|
-
/**
|
|
138
|
-
* reduce metadata into `logObj['-1']` then return stringified `logObj`
|
|
139
|
-
* @param logObj {@link ILogObj}
|
|
140
|
-
* @returns `string`
|
|
141
|
-
*/
|
|
142
|
-
function formatLogObj(logObj) {
|
|
143
|
-
const meta = logObj['_meta'];
|
|
144
|
-
const { logLevelName, date, path } = meta;
|
|
145
|
-
const timestamp = date ? date.toLocaleString() : '';
|
|
146
|
-
const fileInfo = `${path?.filePathWithLine}:${path?.fileColumn}`;
|
|
147
|
-
const methodInfo = `${path?.method ? path.method + '()' : ''}`;
|
|
148
|
-
delete logObj['_meta'];
|
|
149
|
-
logObj['meta0'] = `[${logLevelName}] (${timestamp})`;
|
|
150
|
-
logObj['meta1'] = `${fileInfo} @ ${methodInfo}`;
|
|
151
|
-
return JSON.stringify(logObj, null, 4) + "\n";
|
|
152
|
-
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILogObj, ILogObjMeta } from "tslog";
|
|
1
2
|
/**
|
|
2
3
|
* @param fileName `string` passed into `extractFileName()`
|
|
3
4
|
* @param func `Function` - to get Function.name
|
|
@@ -32,3 +33,9 @@ export declare function formatDebugLogFile(inputFilePath: string, outputFilePath
|
|
|
32
33
|
* @returns `void`
|
|
33
34
|
*/
|
|
34
35
|
export declare function formatAllDebugLogs(logDirectory: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* reduce metadata to two entries, then return stringified `logObj`
|
|
38
|
+
* @param logObj {@link ILogObj}
|
|
39
|
+
* @returns `string`
|
|
40
|
+
*/
|
|
41
|
+
export declare function formatLogObj(logObj: ILogObj | (ILogObj & ILogObjMeta)): string;
|
package/dist/utils/io/logging.js
CHANGED
|
@@ -40,6 +40,7 @@ exports.getSourceString = getSourceString;
|
|
|
40
40
|
exports.autoFormatLogsOnExit = autoFormatLogsOnExit;
|
|
41
41
|
exports.formatDebugLogFile = formatDebugLogFile;
|
|
42
42
|
exports.formatAllDebugLogs = formatAllDebugLogs;
|
|
43
|
+
exports.formatLogObj = formatLogObj;
|
|
43
44
|
/**
|
|
44
45
|
* @file src/utils/io/logging.ts
|
|
45
46
|
*/
|
|
@@ -257,3 +258,24 @@ function formatAllDebugLogs(logDirectory) {
|
|
|
257
258
|
throw error;
|
|
258
259
|
}
|
|
259
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* reduce metadata to two entries, then return stringified `logObj`
|
|
263
|
+
* @param logObj {@link ILogObj}
|
|
264
|
+
* @returns `string`
|
|
265
|
+
*/
|
|
266
|
+
function formatLogObj(logObj) {
|
|
267
|
+
const meta = logObj['_meta'];
|
|
268
|
+
const { logLevelName, date, path: stackFrame } = meta;
|
|
269
|
+
const timestamp = date ? date.toLocaleString() : '';
|
|
270
|
+
if (stackFrame) {
|
|
271
|
+
const fileInfo = [
|
|
272
|
+
stackFrame.filePathWithLine ? `${stackFrame.filePathWithLine}` : '',
|
|
273
|
+
stackFrame.fileColumn && stackFrame.filePathWithLine ? `:${stackFrame.fileColumn}` : '',
|
|
274
|
+
].join('');
|
|
275
|
+
const methodInfo = stackFrame.method ? `${stackFrame.method}()` : '';
|
|
276
|
+
logObj['meta0'] = `[${logLevelName}] (${timestamp})`;
|
|
277
|
+
logObj['meta1'] = `${fileInfo || 'unknown_file'} @ ${methodInfo || 'unknown_method'}`;
|
|
278
|
+
delete logObj['_meta'];
|
|
279
|
+
}
|
|
280
|
+
return JSON.stringify(logObj, null, 4) + "\n";
|
|
281
|
+
}
|