File: helper.ml

package info (click to toggle)
ocaml-obuild 0.1.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 796 kB
  • sloc: ml: 6,570; sh: 171; ansic: 34; makefile: 11
file content (31 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
open Printf
open Gconf

let print_warnings warnings =
    if warnings <> "" then fprintf stderr "%s\n%!" warnings else ()

let log lvl fmt =
    if lvl <= gconf.verbosity
        then printf fmt
        else ifprintf stdout fmt

let debug fmt = log Gconf.Debug fmt
let report fmt = log Gconf.Report fmt

(* deprecated, replace by other stuff *)
let verbose lvl fmt =
    if lvl <= gconf.verbosity
        then printf fmt
        else ifprintf stdout fmt

let support_color () =
    if Utils.isWindows
        then false
    else if Unix.isatty Unix.stdout
        then Gconf.gconf.color
        else false

let color_red ()   = if support_color () then "\x1b[1;31m" else ""
let color_green () = if support_color () then "\x1b[1;32m" else ""
let color_blue ()  = if support_color () then "\x1b[1;34m" else ""
let color_white () = if support_color () then "\x1b[0m" else ""