@@ -13,7 +13,7 @@ open OpamCompat
1313
1414(* Global configuration *)
1515
16- let debug () = OpamCoreConfig. (! r.debug_level) > 0
16+ let debug () = abs OpamCoreConfig. (! r.debug_level) > 0
1717
1818let verbose () = OpamCoreConfig. (! r.verbose_level) > 0
1919
@@ -496,19 +496,21 @@ let timestamp () =
496496 (int_of_float (1000.0 *. msec))
497497
498498let log section ?(level =1 ) fmt =
499- if level < = OpamCoreConfig. (! r.debug_level) then
499+ let debug_level = OpamCoreConfig. (! r.debug_level) in
500+ if level < = abs debug_level then
500501 let () = clear_status () in
502+ let timestamp = if debug_level < 0 then " " else timestamp () ^ " " in
501503 if Sys. win32 then begin
502504 (*
503505 * In order not to break [slog], split the output into two. A side-effect
504506 * of this is that logging lines may not use colour.
505507 *)
506- win32_print_message `stderr (Printf. sprintf " %s %a "
507- ( timestamp () ) (acolor_with_width (Some 30 ) `yellow ) section);
508+ win32_print_message `stderr (Printf. sprintf " %s%a "
509+ timestamp (acolor_with_width (Some 30 ) `yellow ) section);
508510 Printf. fprintf stderr (fmt ^^ " \n %!" ) end
509511 else
510- Printf. fprintf stderr (" %s %a " ^^ fmt ^^ " \n %!" )
511- ( timestamp () ) (acolor_w 30 `yellow ) section
512+ Printf. fprintf stderr (" %s%a " ^^ fmt ^^ " \n %!" )
513+ timestamp (acolor_w 30 `yellow ) section
512514 else
513515 Printf. ifprintf stderr fmt
514516
0 commit comments