@@ -383,7 +383,7 @@ handle_info(secs3, State) ->
383
383
384
384
handle_info ({notify ,{yaws_hupped ,_ }}, State ) ->
385
385
handle_info (minute10 ,State );
386
- % % once every 10 minute , check log sizes
386
+ % % once every 10 minutes , check log sizes
387
387
handle_info (minute10 , State ) ->
388
388
L = lists :map (
389
389
fun (AL ) ->
@@ -437,8 +437,8 @@ wrap(AL, State) ->
437
437
false ->
438
438
AL ;
439
439
enoent ->
440
- % % Logfile disapeared ,
441
- error_logger :format (" Logfile ~p disapeared - we reopen it" ,
440
+ % % Logfile disappeared ,
441
+ error_logger :format (" Logfile ~p disappeared - we reopen it" ,
442
442
[AL # alog .filename ]),
443
443
file :close (AL # alog .fd ),
444
444
{ok , Fd2 } = file :open (AL # alog .filename , [write , raw ]),
@@ -476,9 +476,9 @@ fmt_ip(HostName) ->
476
476
477
477
478
478
fmtnow () ->
479
- {{Year , Month , Date }, {Hour , Min , Sec }} = calendar :local_time (),
480
- io_lib : format ( " [ ~2..0w / ~s / ~4..0w : ~2..0w : ~2..0w : ~2..0w ~s ] " ,
481
- [ Date , yaws : month ( Month ), Year , Hour , Min , Sec , zone ()]) .
479
+ {{Year , Month , Day }, {Hour , Min , Sec }} = calendar :local_time (),
480
+ [ fill_zero ( Day , 2 ), " / " , yaws : month ( Month ), " / " , integer_to_list ( Year ), " : " ,
481
+ fill_zero ( Hour , 2 ), " : " , fill_zero ( Min , 2 ), " : " , fill_zero ( Sec , 2 ), " " , zone ()].
482
482
483
483
zone () ->
484
484
Time = erlang :universaltime (),
@@ -490,6 +490,16 @@ zone() ->
490
490
% % Ugly reformatting code to get times like +0000 and -1300
491
491
492
492
zone (Val ) when Val < 0 ->
493
- io_lib : format ( " - ~4..0w " , [ trunc (abs (Val ))]) ;
493
+ [ $- | fill_zero ( trunc (abs (Val )), 4 )] ;
494
494
zone (Val ) when Val >= 0 ->
495
- io_lib :format (" +~4..0w " , [trunc (abs (Val ))]).
495
+ [$+ |fill_zero (trunc (Val ), 4 )].
496
+
497
+ fill_zero (N , Width ) ->
498
+ left_fill (N , Width , $0 ).
499
+
500
+ left_fill (N , Width , Fill ) when is_integer (N ) ->
501
+ left_fill (integer_to_list (N ), Width , Fill );
502
+ left_fill (N , Width , _Fill ) when length (N ) >= Width ->
503
+ N ;
504
+ left_fill (N , Width , Fill ) ->
505
+ left_fill ([Fill |N ], Width , Fill ).
0 commit comments