Skip to content

Commit 5726460

Browse files
committed
Merge branch 'dev' of https://github.com/wgtechlabs/log-engine into dev
2 parents 58dc7a2 + d6dcf1d commit 5726460

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

src/formatter/data-formatter.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
*/
55

66
/**
7-
* Formats data objects for log output
8-
* Converts objects to readable string format with proper handling of edge cases
9-
* @param data - Data to format (any type)
10-
* @returns Formatted string representation of the data
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
1113
*/
1214
export function formatData(data: any): string {
1315
if (data === null) {
@@ -39,10 +41,11 @@ export function formatData(data: any): string {
3941
}
4042

4143
/**
42-
* Apply data styling with colors
43-
* @param dataString - Formatted data string
44-
* @param colors - Color scheme for data styling
45-
* @returns Colored data string
44+
* Applies color styling to a formatted data string using the provided color codes.
45+
*
46+
* @param dataString - The string to be styled; if falsy, an empty string is returned.
47+
* @param colors - An object containing `data` (the color code prefix) and `reset` (the color code suffix).
48+
* @returns The styled data string with color codes applied, or an empty string if `dataString` is falsy.
4649
*/
4750
export function styleData(dataString: string, colors: { data: string; reset: string }): string {
4851
if (!dataString) {

src/formatter/timestamp.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*/
55

66
/**
7-
* Generate formatted timestamp components for log messages
8-
* Creates both ISO timestamp and localized time string
9-
* @returns Object containing formatted timestamp components
7+
* Generates the current timestamp as both an ISO 8601 string and a compact US English local time string.
8+
*
9+
* @returns An object containing `isoTimestamp` (ISO 8601 format) and `timeString` (localized time string without spaces)
1010
*/
1111
export function getTimestampComponents(): {
1212
isoTimestamp: string;
@@ -27,11 +27,12 @@ export function getTimestampComponents(): {
2727
}
2828

2929
/**
30-
* Format timestamp components with colors for console output
31-
* @param isoTimestamp - ISO formatted timestamp
32-
* @param timeString - Local time string
33-
* @param colors - Color scheme to use
34-
* @returns Formatted and colored timestamp string
30+
* Returns a formatted string combining an ISO timestamp and a local time string, each wrapped with specified color codes for console output.
31+
*
32+
* @param isoTimestamp - The ISO 8601 formatted timestamp to display
33+
* @param timeString - The local time string to display
34+
* @param colors - An object containing color codes for the timestamp, time string, and reset sequence
35+
* @returns The combined, colorized timestamp string suitable for log messages
3536
*/
3637
export function formatTimestamp(
3738
isoTimestamp: string,

0 commit comments

Comments
 (0)