@wgtechlabs/log-engine 2.1.0 → 2.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.
- package/README.md +67 -1
- package/dist/cjs/__tests__/async-test-utils.cjs +276 -0
- package/dist/cjs/__tests__/async-test-utils.d.ts +51 -0
- package/dist/cjs/__tests__/async-test-utils.d.ts.map +1 -0
- package/dist/cjs/__tests__/async-test-utils.js.map +1 -0
- package/dist/cjs/__tests__/redaction/test-utils.cjs +72 -0
- package/dist/cjs/__tests__/redaction/test-utils.d.ts +33 -0
- package/dist/cjs/__tests__/redaction/test-utils.d.ts.map +1 -0
- package/dist/cjs/__tests__/redaction/test-utils.js.map +1 -0
- package/dist/cjs/__tests__/test-utils.cjs +49 -0
- package/dist/cjs/__tests__/test-utils.d.ts +41 -0
- package/dist/cjs/__tests__/test-utils.d.ts.map +1 -0
- package/dist/cjs/__tests__/test-utils.js.map +1 -0
- package/dist/{formatter/colors.js → cjs/formatter/colors.cjs} +1 -0
- package/dist/cjs/formatter/colors.d.ts.map +1 -0
- package/dist/cjs/formatter/colors.js.map +1 -0
- package/dist/{formatter/data-formatter.js → cjs/formatter/data-formatter.cjs} +1 -0
- package/dist/cjs/formatter/data-formatter.d.ts.map +1 -0
- package/dist/cjs/formatter/data-formatter.js.map +1 -0
- package/dist/{formatter/index.js → cjs/formatter/index.cjs} +6 -5
- package/dist/cjs/formatter/index.d.ts.map +1 -0
- package/dist/cjs/formatter/index.js.map +1 -0
- package/dist/{formatter/message-formatter.js → cjs/formatter/message-formatter.cjs} +61 -11
- package/dist/{formatter → cjs/formatter}/message-formatter.d.ts +9 -3
- package/dist/cjs/formatter/message-formatter.d.ts.map +1 -0
- package/dist/cjs/formatter/message-formatter.js.map +1 -0
- package/dist/{formatter/timestamp.js → cjs/formatter/timestamp.cjs} +1 -0
- package/dist/cjs/formatter/timestamp.d.ts.map +1 -0
- package/dist/cjs/formatter/timestamp.js.map +1 -0
- package/dist/{index.js → cjs/index.cjs} +5 -4
- package/dist/{index.d.ts → cjs/index.d.ts} +1 -1
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/{logger/advanced-outputs.js → cjs/logger/advanced-outputs.cjs} +1 -0
- package/dist/cjs/logger/advanced-outputs.d.ts.map +1 -0
- package/dist/cjs/logger/advanced-outputs.js.map +1 -0
- package/dist/{logger/config.js → cjs/logger/config.cjs} +4 -3
- package/dist/cjs/logger/config.d.ts.map +1 -0
- package/dist/cjs/logger/config.js.map +1 -0
- package/dist/{logger/core.js → cjs/logger/core.cjs} +48 -16
- package/dist/{logger → cjs/logger}/core.d.ts +19 -0
- package/dist/cjs/logger/core.d.ts.map +1 -0
- package/dist/cjs/logger/core.js.map +1 -0
- package/dist/{logger/environment.js → cjs/logger/environment.cjs} +2 -1
- package/dist/cjs/logger/environment.d.ts.map +1 -0
- package/dist/cjs/logger/environment.js.map +1 -0
- package/dist/{logger/filtering.js → cjs/logger/filtering.cjs} +2 -1
- package/dist/cjs/logger/filtering.d.ts.map +1 -0
- package/dist/cjs/logger/filtering.js.map +1 -0
- package/dist/{logger/index.js → cjs/logger/index.cjs} +6 -5
- package/dist/cjs/logger/index.d.ts.map +1 -0
- package/dist/cjs/logger/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/{redaction/config.js → cjs/redaction/config.cjs} +1 -0
- package/dist/cjs/redaction/config.d.ts.map +1 -0
- package/dist/cjs/redaction/config.js.map +1 -0
- package/dist/{redaction/index.js → cjs/redaction/index.cjs} +3 -2
- package/dist/cjs/redaction/index.d.ts.map +1 -0
- package/dist/cjs/redaction/index.js.map +1 -0
- package/dist/{redaction/redactor.js → cjs/redaction/redactor.cjs} +2 -1
- package/dist/cjs/redaction/redactor.d.ts.map +1 -0
- package/dist/cjs/redaction/redactor.js.map +1 -0
- package/dist/{types/index.js → cjs/types/index.cjs} +1 -0
- package/dist/{types → cjs/types}/index.d.ts +12 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/esm/__tests__/async-test-utils.d.ts +51 -0
- package/dist/esm/__tests__/async-test-utils.d.ts.map +1 -0
- package/dist/esm/__tests__/async-test-utils.js +231 -0
- package/dist/esm/__tests__/async-test-utils.js.map +1 -0
- package/dist/esm/__tests__/redaction/test-utils.d.ts +33 -0
- package/dist/esm/__tests__/redaction/test-utils.d.ts.map +1 -0
- package/dist/esm/__tests__/redaction/test-utils.js +65 -0
- package/dist/esm/__tests__/redaction/test-utils.js.map +1 -0
- package/dist/esm/__tests__/test-utils.d.ts +41 -0
- package/dist/esm/__tests__/test-utils.d.ts.map +1 -0
- package/dist/esm/__tests__/test-utils.js +42 -0
- package/dist/esm/__tests__/test-utils.js.map +1 -0
- package/dist/esm/formatter/colors.d.ts +32 -0
- package/dist/esm/formatter/colors.d.ts.map +1 -0
- package/dist/esm/formatter/colors.js +32 -0
- package/dist/esm/formatter/colors.js.map +1 -0
- package/dist/esm/formatter/data-formatter.d.ts +26 -0
- package/dist/esm/formatter/data-formatter.d.ts.map +1 -0
- package/dist/esm/formatter/data-formatter.js +50 -0
- package/dist/esm/formatter/data-formatter.js.map +1 -0
- package/dist/esm/formatter/index.d.ts +10 -0
- package/dist/esm/formatter/index.d.ts.map +1 -0
- package/dist/esm/formatter/index.js +11 -0
- package/dist/esm/formatter/index.js.map +1 -0
- package/dist/esm/formatter/message-formatter.d.ts +47 -0
- package/dist/esm/formatter/message-formatter.d.ts.map +1 -0
- package/dist/esm/formatter/message-formatter.js +133 -0
- package/dist/esm/formatter/message-formatter.js.map +1 -0
- package/dist/esm/formatter/timestamp.d.ts +27 -0
- package/dist/esm/formatter/timestamp.d.ts.map +1 -0
- package/dist/esm/formatter/timestamp.js +36 -0
- package/dist/esm/formatter/timestamp.js.map +1 -0
- package/dist/esm/index.d.ts +180 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +194 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logger/advanced-outputs.d.ts +159 -0
- package/dist/esm/logger/advanced-outputs.d.ts.map +1 -0
- package/dist/esm/logger/advanced-outputs.js +542 -0
- package/dist/esm/logger/advanced-outputs.js.map +1 -0
- package/dist/esm/logger/config.d.ts +42 -0
- package/dist/esm/logger/config.d.ts.map +1 -0
- package/dist/esm/logger/config.js +101 -0
- package/dist/esm/logger/config.js.map +1 -0
- package/dist/esm/logger/core.d.ts +171 -0
- package/dist/esm/logger/core.d.ts.map +1 -0
- package/dist/esm/logger/core.js +398 -0
- package/dist/esm/logger/core.js.map +1 -0
- package/dist/esm/logger/environment.d.ts +36 -0
- package/dist/esm/logger/environment.d.ts.map +1 -0
- package/dist/esm/logger/environment.js +58 -0
- package/dist/esm/logger/environment.js.map +1 -0
- package/dist/esm/logger/filtering.d.ts +36 -0
- package/dist/esm/logger/filtering.d.ts.map +1 -0
- package/dist/esm/logger/filtering.js +77 -0
- package/dist/esm/logger/filtering.js.map +1 -0
- package/dist/esm/logger/index.d.ts +10 -0
- package/dist/esm/logger/index.d.ts.map +1 -0
- package/dist/esm/logger/index.js +11 -0
- package/dist/esm/logger/index.js.map +1 -0
- package/dist/esm/redaction/config.d.ts +29 -0
- package/dist/esm/redaction/config.d.ts.map +1 -0
- package/dist/esm/redaction/config.js +92 -0
- package/dist/esm/redaction/config.js.map +1 -0
- package/dist/esm/redaction/index.d.ts +8 -0
- package/dist/esm/redaction/index.d.ts.map +1 -0
- package/dist/esm/redaction/index.js +7 -0
- package/dist/esm/redaction/index.js.map +1 -0
- package/dist/esm/redaction/redactor.d.ts +99 -0
- package/dist/esm/redaction/redactor.d.ts.map +1 -0
- package/dist/esm/redaction/redactor.js +259 -0
- package/dist/esm/redaction/redactor.js.map +1 -0
- package/dist/esm/types/index.d.ts +322 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +41 -0
- package/dist/esm/types/index.js.map +1 -0
- package/package.json +59 -10
- package/dist/formatter/colors.d.ts.map +0 -1
- package/dist/formatter/data-formatter.d.ts.map +0 -1
- package/dist/formatter/index.d.ts.map +0 -1
- package/dist/formatter/message-formatter.d.ts.map +0 -1
- package/dist/formatter/timestamp.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/logger/advanced-outputs.d.ts.map +0 -1
- package/dist/logger/config.d.ts.map +0 -1
- package/dist/logger/core.d.ts.map +0 -1
- package/dist/logger/environment.d.ts.map +0 -1
- package/dist/logger/filtering.d.ts.map +0 -1
- package/dist/logger/index.d.ts.map +0 -1
- package/dist/redaction/config.d.ts.map +0 -1
- package/dist/redaction/index.d.ts.map +0 -1
- package/dist/redaction/redactor.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- /package/dist/{formatter → cjs/formatter}/colors.d.ts +0 -0
- /package/dist/{formatter → cjs/formatter}/data-formatter.d.ts +0 -0
- /package/dist/{formatter → cjs/formatter}/index.d.ts +0 -0
- /package/dist/{formatter → cjs/formatter}/timestamp.d.ts +0 -0
- /package/dist/{logger → cjs/logger}/advanced-outputs.d.ts +0 -0
- /package/dist/{logger → cjs/logger}/config.d.ts +0 -0
- /package/dist/{logger → cjs/logger}/environment.d.ts +0 -0
- /package/dist/{logger → cjs/logger}/filtering.d.ts +0 -0
- /package/dist/{logger → cjs/logger}/index.d.ts +0 -0
- /package/dist/{redaction → cjs/redaction}/config.d.ts +0 -0
- /package/dist/{redaction → cjs/redaction}/index.d.ts +0 -0
- /package/dist/{redaction → cjs/redaction}/redactor.d.ts +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared test utilities for log-engine tests
|
|
3
|
+
* Provides consistent console mocking and cleanup functionality across all test suites
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Sets up console mocks for testing log output
|
|
7
|
+
* Replaces console methods with Jest spies to capture and verify log calls
|
|
8
|
+
* @returns ConsoleMocks object containing all spy instances
|
|
9
|
+
*/
|
|
10
|
+
export const setupConsoleMocks = () => {
|
|
11
|
+
const mockConsoleLog = jest.spyOn(console, 'log').mockImplementation();
|
|
12
|
+
const mockConsoleWarn = jest.spyOn(console, 'warn').mockImplementation();
|
|
13
|
+
const mockConsoleError = jest.spyOn(console, 'error').mockImplementation();
|
|
14
|
+
return { mockConsoleLog, mockConsoleWarn, mockConsoleError };
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Restores console mocks after testing
|
|
18
|
+
* Cleans up Jest spies and restores original console functionality
|
|
19
|
+
* @param mocks - The ConsoleMocks object from setupConsoleMocks
|
|
20
|
+
*/
|
|
21
|
+
export const restoreConsoleMocks = (mocks) => {
|
|
22
|
+
mocks.mockConsoleLog.mockRestore();
|
|
23
|
+
mocks.mockConsoleWarn.mockRestore();
|
|
24
|
+
mocks.mockConsoleError.mockRestore();
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Convenience function for setting up console mocks in beforeEach hooks
|
|
28
|
+
* Identical to setupConsoleMocks but with a more descriptive name for test setup
|
|
29
|
+
* @returns ConsoleMocks object containing all spy instances
|
|
30
|
+
*/
|
|
31
|
+
export const setupConsoleBeforeEach = () => {
|
|
32
|
+
return setupConsoleMocks();
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Convenience function for restoring console mocks in afterEach hooks
|
|
36
|
+
* Identical to restoreConsoleMocks but with a more descriptive name for test cleanup
|
|
37
|
+
* @param mocks - The ConsoleMocks object to restore
|
|
38
|
+
*/
|
|
39
|
+
export const restoreConsoleAfterEach = (mocks) => {
|
|
40
|
+
restoreConsoleMocks(mocks);
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=test-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../../src/__tests__/test-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAiB,EAAE;IAClD,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACvE,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACzE,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,EAAE,CAAC;IAE3E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC;AAC/D,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAmB,EAAQ,EAAE;IAC/D,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;IACnC,KAAK,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;IACpC,KAAK,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC;AACvC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAiB,EAAE;IACvD,OAAO,iBAAiB,EAAE,CAAC;AAC7B,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAmB,EAAQ,EAAE;IACnE,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ANSI color codes and color management for terminal output
|
|
3
|
+
* Provides consistent color definitions used throughout the formatting system
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* ANSI color codes for terminal output styling
|
|
7
|
+
* Used to create colorized console output with consistent theming
|
|
8
|
+
*/
|
|
9
|
+
export declare const colors: {
|
|
10
|
+
readonly reset: "\u001B[0m";
|
|
11
|
+
readonly dim: "\u001B[2m";
|
|
12
|
+
readonly red: "\u001B[31m";
|
|
13
|
+
readonly yellow: "\u001B[33m";
|
|
14
|
+
readonly blue: "\u001B[34m";
|
|
15
|
+
readonly magenta: "\u001B[35m";
|
|
16
|
+
readonly cyan: "\u001B[36m";
|
|
17
|
+
readonly white: "\u001B[37m";
|
|
18
|
+
readonly gray: "\u001B[90m";
|
|
19
|
+
readonly green: "\u001B[32m";
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Color scheme configuration
|
|
23
|
+
* Maps semantic meanings to specific colors for consistent theming
|
|
24
|
+
*/
|
|
25
|
+
export declare const colorScheme: {
|
|
26
|
+
readonly timestamp: "\u001B[90m";
|
|
27
|
+
readonly timeString: "\u001B[36m";
|
|
28
|
+
readonly system: "\u001B[33m";
|
|
29
|
+
readonly data: "\u001B[2m";
|
|
30
|
+
readonly reset: "\u001B[0m";
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/formatter/colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;CAWT,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;CAMd,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ANSI color codes and color management for terminal output
|
|
3
|
+
* Provides consistent color definitions used throughout the formatting system
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* ANSI color codes for terminal output styling
|
|
7
|
+
* Used to create colorized console output with consistent theming
|
|
8
|
+
*/
|
|
9
|
+
export const colors = {
|
|
10
|
+
reset: '\x1b[0m', // Reset all formatting
|
|
11
|
+
dim: '\x1b[2m', // Dim/faded text
|
|
12
|
+
red: '\x1b[31m', // Red text (errors)
|
|
13
|
+
yellow: '\x1b[33m', // Yellow text (warnings)
|
|
14
|
+
blue: '\x1b[34m', // Blue text (info)
|
|
15
|
+
magenta: '\x1b[35m', // Magenta text (debug)
|
|
16
|
+
cyan: '\x1b[36m', // Cyan text (timestamps)
|
|
17
|
+
white: '\x1b[37m', // White text (default)
|
|
18
|
+
gray: '\x1b[90m', // Gray text (timestamps)
|
|
19
|
+
green: '\x1b[32m' // Green text (log level)
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Color scheme configuration
|
|
23
|
+
* Maps semantic meanings to specific colors for consistent theming
|
|
24
|
+
*/
|
|
25
|
+
export const colorScheme = {
|
|
26
|
+
timestamp: colors.gray,
|
|
27
|
+
timeString: colors.cyan,
|
|
28
|
+
system: colors.yellow,
|
|
29
|
+
data: colors.dim,
|
|
30
|
+
reset: colors.reset
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../../src/formatter/colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,SAAS,EAAO,uBAAuB;IAC9C,GAAG,EAAE,SAAS,EAAS,iBAAiB;IACxC,GAAG,EAAE,UAAU,EAAQ,oBAAoB;IAC3C,MAAM,EAAE,UAAU,EAAK,yBAAyB;IAChD,IAAI,EAAE,UAAU,EAAO,mBAAmB;IAC1C,OAAO,EAAE,UAAU,EAAI,uBAAuB;IAC9C,IAAI,EAAE,UAAU,EAAO,yBAAyB;IAChD,KAAK,EAAE,UAAU,EAAM,uBAAuB;IAC9C,IAAI,EAAE,UAAU,EAAO,yBAAyB;IAChD,KAAK,EAAE,UAAU,CAAM,yBAAyB;CACxC,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC,IAAI;IACtB,UAAU,EAAE,MAAM,CAAC,IAAI;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC,KAAK;CACX,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data formatting utilities for log output
|
|
3
|
+
* Handles serialization and formatting of data objects in log messages
|
|
4
|
+
*/
|
|
5
|
+
import { LogData } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Converts input data to a readable string suitable for log output.
|
|
8
|
+
*
|
|
9
|
+
* Returns 'null' for `null`, an empty string for `undefined`, the value itself for strings, and string representations for numbers and booleans. For other types, attempts JSON serialization; if serialization fails, returns '[Object]'.
|
|
10
|
+
*
|
|
11
|
+
* @param data - The value to format for logging
|
|
12
|
+
* @returns The formatted string representation of the input data
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatData(data: LogData): string;
|
|
15
|
+
/**
|
|
16
|
+
* Applies color styling to a formatted data string using the provided color codes.
|
|
17
|
+
*
|
|
18
|
+
* @param dataString - The string to be styled; if falsy, an empty string is returned.
|
|
19
|
+
* @param colors - An object containing `data` (the color code prefix) and `reset` (the color code suffix).
|
|
20
|
+
* @returns The styled data string with color codes applied, or an empty string if `dataString` is falsy.
|
|
21
|
+
*/
|
|
22
|
+
export declare function styleData(dataString: string, colors: {
|
|
23
|
+
data: string;
|
|
24
|
+
reset: string;
|
|
25
|
+
}): string;
|
|
26
|
+
//# sourceMappingURL=data-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-formatter.d.ts","sourceRoot":"","sources":["../../../src/formatter/data-formatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CA2BhD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAM7F"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data formatting utilities for log output
|
|
3
|
+
* Handles serialization and formatting of data objects in log messages
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Converts input data to a readable string suitable for log output.
|
|
7
|
+
*
|
|
8
|
+
* Returns 'null' for `null`, an empty string for `undefined`, the value itself for strings, and string representations for numbers and booleans. For other types, attempts JSON serialization; if serialization fails, returns '[Object]'.
|
|
9
|
+
*
|
|
10
|
+
* @param data - The value to format for logging
|
|
11
|
+
* @returns The formatted string representation of the input data
|
|
12
|
+
*/
|
|
13
|
+
export function formatData(data) {
|
|
14
|
+
if (data === null) {
|
|
15
|
+
return 'null';
|
|
16
|
+
}
|
|
17
|
+
if (data === undefined) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
if (typeof data === 'string') {
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
if (typeof data === 'number' || typeof data === 'boolean') {
|
|
24
|
+
return String(data);
|
|
25
|
+
}
|
|
26
|
+
if (typeof data === 'symbol') {
|
|
27
|
+
return data.toString();
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
return JSON.stringify(data, null, 0);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Fallback for objects that can't be stringified (e.g., circular references)
|
|
34
|
+
return '[Object]';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Applies color styling to a formatted data string using the provided color codes.
|
|
39
|
+
*
|
|
40
|
+
* @param dataString - The string to be styled; if falsy, an empty string is returned.
|
|
41
|
+
* @param colors - An object containing `data` (the color code prefix) and `reset` (the color code suffix).
|
|
42
|
+
* @returns The styled data string with color codes applied, or an empty string if `dataString` is falsy.
|
|
43
|
+
*/
|
|
44
|
+
export function styleData(dataString, colors) {
|
|
45
|
+
if (!dataString) {
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
return ` ${colors.data}${dataString}${colors.reset}`;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=data-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-formatter.js","sourceRoot":"","sources":["../../../src/formatter/data-formatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,IAAa;IACtC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1D,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,6EAA6E;QAC7E,OAAO,UAAU,CAAC;IACpB,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,UAAkB,EAAE,MAAuC;IACnF,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,IAAI,MAAM,CAAC,IAAI,GAAG,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatter module exports
|
|
3
|
+
* Provides centralized access to all formatting functionality
|
|
4
|
+
*/
|
|
5
|
+
export { MessageFormatter } from './message-formatter';
|
|
6
|
+
export { colors, colorScheme } from './colors';
|
|
7
|
+
export { getTimestampComponents, formatTimestamp } from './timestamp';
|
|
8
|
+
export { formatData, styleData } from './data-formatter';
|
|
9
|
+
export { MessageFormatter as LogFormatter } from './message-formatter';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formatter/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAE,gBAAgB,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatter module exports
|
|
3
|
+
* Provides centralized access to all formatting functionality
|
|
4
|
+
*/
|
|
5
|
+
export { MessageFormatter } from './message-formatter.js';
|
|
6
|
+
export { colors, colorScheme } from './colors.js';
|
|
7
|
+
export { getTimestampComponents, formatTimestamp } from './timestamp.js';
|
|
8
|
+
export { formatData, styleData } from './data-formatter.js';
|
|
9
|
+
// Backward compatibility - maintain the original LogFormatter class interface
|
|
10
|
+
export { MessageFormatter as LogFormatter } from './message-formatter.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatter/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEzD,8EAA8E;AAC9E,OAAO,EAAE,gBAAgB,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core message formatting functionality
|
|
3
|
+
* Handles the main log message formatting with colors, timestamps, and levels
|
|
4
|
+
*/
|
|
5
|
+
import { LogLevel, LogData, LogFormatConfig } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Core message formatter class
|
|
8
|
+
* Provides the main formatting functionality for log messages
|
|
9
|
+
*/
|
|
10
|
+
export declare class MessageFormatter {
|
|
11
|
+
/**
|
|
12
|
+
* Default format configuration to avoid object recreation on every call
|
|
13
|
+
*/
|
|
14
|
+
private static readonly DEFAULT_FORMAT_CONFIG;
|
|
15
|
+
/**
|
|
16
|
+
* Formats a log message with timestamp, level indicator, and appropriate coloring
|
|
17
|
+
* Creates a structured log entry: [ISO_TIMESTAMP][LOCAL_TIME][LEVEL]: message [data]
|
|
18
|
+
* @param level - The log level to format for
|
|
19
|
+
* @param message - The message content to format
|
|
20
|
+
* @param data - Optional data object to include in the log output
|
|
21
|
+
* @param formatConfig - Optional format configuration to control element inclusion
|
|
22
|
+
* @returns Formatted string with ANSI colors and timestamps
|
|
23
|
+
*/
|
|
24
|
+
static format(level: LogLevel, message: string, data?: LogData, formatConfig?: LogFormatConfig): string;
|
|
25
|
+
/**
|
|
26
|
+
* Formats a Log Engine system message with [LOG ENGINE] prefix instead of log levels
|
|
27
|
+
* Used for internal messages like deprecation warnings that should be distinguished from user logs
|
|
28
|
+
* @param message - The system message content to format
|
|
29
|
+
* @param formatConfig - Optional format configuration to control element inclusion
|
|
30
|
+
* @returns Formatted string with ANSI colors, timestamps, and LOG ENGINE prefix
|
|
31
|
+
*/
|
|
32
|
+
static formatSystemMessage(message: string, formatConfig?: LogFormatConfig): string;
|
|
33
|
+
/**
|
|
34
|
+
* Converts LogLevel enum to human-readable string
|
|
35
|
+
* @param level - The LogLevel to convert
|
|
36
|
+
* @returns String representation of the log level
|
|
37
|
+
*/
|
|
38
|
+
private static getLevelName;
|
|
39
|
+
/**
|
|
40
|
+
* Maps LogLevel to appropriate ANSI color code
|
|
41
|
+
* Colors help quickly identify message severity in console output
|
|
42
|
+
* @param level - The LogLevel to get color for
|
|
43
|
+
* @returns ANSI color escape sequence
|
|
44
|
+
*/
|
|
45
|
+
private static getLevelColor;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=message-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-formatter.d.ts","sourceRoot":"","sources":["../../../src/formatter/message-formatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAK9D;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAG3C;IAEF;;;;;;;;SAQK;IACL,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,eAAe,GAAG,MAAM;IA0CvG;;;;;;SAMK;IACL,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,eAAe,GAAG,MAAM;IA8BnF;;;;SAIK;IACL,OAAO,CAAC,MAAM,CAAC,YAAY;IAW3B;;;;;SAKK;IACL,OAAO,CAAC,MAAM,CAAC,aAAa;CAU7B"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core message formatting functionality
|
|
3
|
+
* Handles the main log message formatting with colors, timestamps, and levels
|
|
4
|
+
*/
|
|
5
|
+
import { LogLevel } from '../types/index.js';
|
|
6
|
+
import { colors, colorScheme } from './colors.js';
|
|
7
|
+
import { getTimestampComponents, formatTimestamp } from './timestamp.js';
|
|
8
|
+
import { formatData, styleData } from './data-formatter.js';
|
|
9
|
+
/**
|
|
10
|
+
* Core message formatter class
|
|
11
|
+
* Provides the main formatting functionality for log messages
|
|
12
|
+
*/
|
|
13
|
+
export class MessageFormatter {
|
|
14
|
+
/**
|
|
15
|
+
* Formats a log message with timestamp, level indicator, and appropriate coloring
|
|
16
|
+
* Creates a structured log entry: [ISO_TIMESTAMP][LOCAL_TIME][LEVEL]: message [data]
|
|
17
|
+
* @param level - The log level to format for
|
|
18
|
+
* @param message - The message content to format
|
|
19
|
+
* @param data - Optional data object to include in the log output
|
|
20
|
+
* @param formatConfig - Optional format configuration to control element inclusion
|
|
21
|
+
* @returns Formatted string with ANSI colors and timestamps
|
|
22
|
+
*/
|
|
23
|
+
static format(level, message, data, formatConfig) {
|
|
24
|
+
// Merge provided format configuration with the default configuration
|
|
25
|
+
const config = {
|
|
26
|
+
...MessageFormatter.DEFAULT_FORMAT_CONFIG,
|
|
27
|
+
...formatConfig
|
|
28
|
+
};
|
|
29
|
+
// Build timestamp string conditionally
|
|
30
|
+
let timestamp = '';
|
|
31
|
+
if (config.includeIsoTimestamp || config.includeLocalTime) {
|
|
32
|
+
const { isoTimestamp, timeString } = getTimestampComponents();
|
|
33
|
+
if (config.includeIsoTimestamp && config.includeLocalTime) {
|
|
34
|
+
// Both timestamps included
|
|
35
|
+
timestamp = formatTimestamp(isoTimestamp, timeString, colorScheme);
|
|
36
|
+
}
|
|
37
|
+
else if (config.includeIsoTimestamp) {
|
|
38
|
+
// Only ISO timestamp
|
|
39
|
+
timestamp = `${colorScheme.timestamp}[${isoTimestamp}]${colors.reset}`;
|
|
40
|
+
}
|
|
41
|
+
else if (config.includeLocalTime) {
|
|
42
|
+
// Only local time
|
|
43
|
+
timestamp = `${colorScheme.timeString}[${timeString}]${colors.reset}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const levelName = MessageFormatter.getLevelName(level);
|
|
47
|
+
const levelColor = MessageFormatter.getLevelColor(level);
|
|
48
|
+
const coloredLevel = `${levelColor}[${levelName}]${colors.reset}`;
|
|
49
|
+
// Format the base message (level is always included as per requirements)
|
|
50
|
+
let formattedMessage = `${timestamp}${coloredLevel}: ${message}`;
|
|
51
|
+
// Append data if provided
|
|
52
|
+
if (data !== undefined) {
|
|
53
|
+
const dataString = formatData(data);
|
|
54
|
+
const styledData = styleData(dataString, colorScheme);
|
|
55
|
+
formattedMessage += styledData;
|
|
56
|
+
}
|
|
57
|
+
// Always reset colors at the end of the entire log line
|
|
58
|
+
return formattedMessage + colors.reset;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Formats a Log Engine system message with [LOG ENGINE] prefix instead of log levels
|
|
62
|
+
* Used for internal messages like deprecation warnings that should be distinguished from user logs
|
|
63
|
+
* @param message - The system message content to format
|
|
64
|
+
* @param formatConfig - Optional format configuration to control element inclusion
|
|
65
|
+
* @returns Formatted string with ANSI colors, timestamps, and LOG ENGINE prefix
|
|
66
|
+
*/
|
|
67
|
+
static formatSystemMessage(message, formatConfig) {
|
|
68
|
+
// Merge provided format configuration with the default configuration
|
|
69
|
+
const config = {
|
|
70
|
+
...MessageFormatter.DEFAULT_FORMAT_CONFIG,
|
|
71
|
+
...formatConfig
|
|
72
|
+
};
|
|
73
|
+
// Build timestamp string conditionally
|
|
74
|
+
let timestamp = '';
|
|
75
|
+
if (config.includeIsoTimestamp || config.includeLocalTime) {
|
|
76
|
+
const { isoTimestamp, timeString } = getTimestampComponents();
|
|
77
|
+
if (config.includeIsoTimestamp && config.includeLocalTime) {
|
|
78
|
+
// Both timestamps included
|
|
79
|
+
timestamp = formatTimestamp(isoTimestamp, timeString, colorScheme);
|
|
80
|
+
}
|
|
81
|
+
else if (config.includeIsoTimestamp) {
|
|
82
|
+
// Only ISO timestamp
|
|
83
|
+
timestamp = `${colorScheme.timestamp}[${isoTimestamp}]${colors.reset}`;
|
|
84
|
+
}
|
|
85
|
+
else if (config.includeLocalTime) {
|
|
86
|
+
// Only local time
|
|
87
|
+
timestamp = `${colorScheme.timeString}[${timeString}]${colors.reset}`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const coloredLogEngine = `${colorScheme.system}[LOG ENGINE]${colors.reset}`;
|
|
91
|
+
const coloredMessage = `${colorScheme.system}${message}${colors.reset}`;
|
|
92
|
+
return `${timestamp}${coloredLogEngine}: ${coloredMessage}`;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Converts LogLevel enum to human-readable string
|
|
96
|
+
* @param level - The LogLevel to convert
|
|
97
|
+
* @returns String representation of the log level
|
|
98
|
+
*/
|
|
99
|
+
static getLevelName(level) {
|
|
100
|
+
switch (level) {
|
|
101
|
+
case LogLevel.DEBUG: return 'DEBUG';
|
|
102
|
+
case LogLevel.INFO: return 'INFO';
|
|
103
|
+
case LogLevel.WARN: return 'WARN';
|
|
104
|
+
case LogLevel.ERROR: return 'ERROR';
|
|
105
|
+
case LogLevel.LOG: return 'LOG';
|
|
106
|
+
default: return 'UNKNOWN';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Maps LogLevel to appropriate ANSI color code
|
|
111
|
+
* Colors help quickly identify message severity in console output
|
|
112
|
+
* @param level - The LogLevel to get color for
|
|
113
|
+
* @returns ANSI color escape sequence
|
|
114
|
+
*/
|
|
115
|
+
static getLevelColor(level) {
|
|
116
|
+
switch (level) {
|
|
117
|
+
case LogLevel.DEBUG: return colors.magenta; // Purple for debug info
|
|
118
|
+
case LogLevel.INFO: return colors.blue; // Blue for general info
|
|
119
|
+
case LogLevel.WARN: return colors.yellow; // Yellow for warnings
|
|
120
|
+
case LogLevel.ERROR: return colors.red; // Red for errors
|
|
121
|
+
case LogLevel.LOG: return colors.green; // Green for always-on log messages
|
|
122
|
+
default: return colors.white; // White for unknown levels
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Default format configuration to avoid object recreation on every call
|
|
128
|
+
*/
|
|
129
|
+
MessageFormatter.DEFAULT_FORMAT_CONFIG = {
|
|
130
|
+
includeIsoTimestamp: true,
|
|
131
|
+
includeLocalTime: true
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=message-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-formatter.js","sourceRoot":"","sources":["../../../src/formatter/message-formatter.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timestamp formatting utilities
|
|
3
|
+
* Handles ISO timestamp and local time formatting for log messages
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generates the current timestamp as both an ISO 8601 string and a compact US English local time string.
|
|
7
|
+
*
|
|
8
|
+
* @returns An object containing `isoTimestamp` (ISO 8601 format) and `timeString` (localized time string without spaces)
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTimestampComponents(): {
|
|
11
|
+
isoTimestamp: string;
|
|
12
|
+
timeString: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Returns a formatted string combining an ISO timestamp and a local time string, each wrapped with specified color codes for console output.
|
|
16
|
+
*
|
|
17
|
+
* @param isoTimestamp - The ISO 8601 formatted timestamp to display
|
|
18
|
+
* @param timeString - The local time string to display
|
|
19
|
+
* @param colors - An object containing color codes for the timestamp, time string, and reset sequence
|
|
20
|
+
* @returns The combined, colorized timestamp string suitable for log messages
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatTimestamp(isoTimestamp: string, timeString: string, colors: {
|
|
23
|
+
timestamp: string;
|
|
24
|
+
timeString: string;
|
|
25
|
+
reset: string;
|
|
26
|
+
}): string;
|
|
27
|
+
//# sourceMappingURL=timestamp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamp.d.ts","sourceRoot":"","sources":["../../../src/formatter/timestamp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CAClB,CAaJ;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/D,MAAM,CAKR"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timestamp formatting utilities
|
|
3
|
+
* Handles ISO timestamp and local time formatting for log messages
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generates the current timestamp as both an ISO 8601 string and a compact US English local time string.
|
|
7
|
+
*
|
|
8
|
+
* @returns An object containing `isoTimestamp` (ISO 8601 format) and `timeString` (localized time string without spaces)
|
|
9
|
+
*/
|
|
10
|
+
export function getTimestampComponents() {
|
|
11
|
+
const now = new Date();
|
|
12
|
+
const isoTimestamp = now.toISOString();
|
|
13
|
+
const timeString = now.toLocaleTimeString('en-US', {
|
|
14
|
+
hour: 'numeric',
|
|
15
|
+
minute: '2-digit',
|
|
16
|
+
hour12: true
|
|
17
|
+
}).replace(/\s+/g, '');
|
|
18
|
+
return {
|
|
19
|
+
isoTimestamp,
|
|
20
|
+
timeString
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns a formatted string combining an ISO timestamp and a local time string, each wrapped with specified color codes for console output.
|
|
25
|
+
*
|
|
26
|
+
* @param isoTimestamp - The ISO 8601 formatted timestamp to display
|
|
27
|
+
* @param timeString - The local time string to display
|
|
28
|
+
* @param colors - An object containing color codes for the timestamp, time string, and reset sequence
|
|
29
|
+
* @returns The combined, colorized timestamp string suitable for log messages
|
|
30
|
+
*/
|
|
31
|
+
export function formatTimestamp(isoTimestamp, timeString, colors) {
|
|
32
|
+
const coloredTimestamp = `${colors.timestamp}[${isoTimestamp}]${colors.reset}`;
|
|
33
|
+
const coloredTimeString = `${colors.timeString}[${timeString}]${colors.reset}`;
|
|
34
|
+
return `${coloredTimestamp}${coloredTimeString}`;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=timestamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../../../src/formatter/timestamp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IAIpC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,YAAY,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IACvC,MAAM,UAAU,GAAG,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE;QACjD,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,IAAI;KACb,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEvB,OAAO;QACL,YAAY;QACZ,UAAU;KACX,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,YAAoB,EACpB,UAAkB,EAClB,MAAgE;IAEhE,MAAM,gBAAgB,GAAG,GAAG,MAAM,CAAC,SAAS,IAAI,YAAY,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/E,MAAM,iBAAiB,GAAG,GAAG,MAAM,CAAC,UAAU,IAAI,UAAU,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;IAE/E,OAAO,GAAG,gBAAgB,GAAG,iBAAiB,EAAE,CAAC;AACnD,CAAC"}
|