Skip to content

Commit

Permalink
Merge pull request #87 from skalenetwork/ticket-85-fix-timestamp-format
Browse files Browse the repository at this point in the history
ticket-86 fixed timestamp formatting in logs
  • Loading branch information
sergiy-skalelabs authored Feb 7, 2024
2 parents 7a8b166 + 4f7966d commit e1cd9fb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function setPrintTimestamps( b?: boolean ): void {
}

export function n2s( n: any, sz: number ): string {
let s: string = n ?? "";
let s: string = n ? n.toString() : "";
while( s.length < sz )
s = "0" + s;
return s;
Expand All @@ -168,6 +168,8 @@ export function generateTimestampString( ts?: any, isColorized?: boolean ): stri
( typeof isColorized === "undefined" )
? true
: ( !!isColorized );
if( isColorized )
isColorized = cc.isEnabled();
ts = ( ts instanceof Date ) ? ts : new Date();
const ccDate = function( x?: any ): string { return isColorized ? cc.date( x ) : x; };
const ccTime = function( x?: any ): string { return isColorized ? cc.time( x ) : x; };
Expand All @@ -182,7 +184,6 @@ export function generateTimestampString( ts?: any, isColorized?: boolean ): stri
ccBright( ":" ) + ccTime( n2s( ts.getUTCMinutes(), 2 ) ) +
ccBright( ":" ) + ccTime( n2s( ts.getUTCSeconds(), 2 ) ) +
ccBright( "." ) + ccFractionPartOfTime( n2s( ts.getUTCMilliseconds(), 3 ) );

return s;
}

Expand Down

0 comments on commit e1cd9fb

Please sign in to comment.