@@ -19,14 +19,20 @@ export type Log = LogFn & {
1919
2020type LogLevel = keyof typeof colors
2121
22+ const formatDate = ( date : Date ) => {
23+ return [ date . getHours ( ) , date . getMinutes ( ) , date . getSeconds ( ) ]
24+ . map ( ( n ) => n . toString ( ) . padStart ( 2 , '0' ) )
25+ . join ( ':' )
26+ }
27+
2228/**
2329 * Logs a message to the console. The level is displayed in ANSI colors,
2430 * either bright red in case of an error or green otherwise.
2531 */
2632export const makeLog = function ( cfg : Config ) {
2733 function log ( msg : string , level : LogLevel ) {
2834 if ( cfg . quiet && level === 'info' ) return
29- if ( cfg . timestamp ) msg = color ( new Date ( cfg . timestamp ) . toLocaleString ( ) , '30;1' ) + ' ' + msg
35+ if ( cfg . timestamp ) msg = color ( formatDate ( new Date ( ) ) , '30;1' ) + ' ' + msg
3036 const c = colors [ level . toLowerCase ( ) as LogLevel ] || '32'
3137 console . log ( '[' + color ( level . toUpperCase ( ) , c ) + '] ' + msg )
3238 }
@@ -42,7 +48,7 @@ export const makeLog = function (cfg: Config) {
4248 if ( ! cfg . debug ) return
4349 log ( util . format . apply ( util , arguments ) , 'debug' )
4450 }
45- log . info = function ( ) {
51+ log . info = function ( ) {
4652 log ( util . format . apply ( util , arguments ) , 'info' )
4753 }
4854
0 commit comments