Add unique ids to each Hack build, and handle sigint
[hiphop-php.git] / hphp / hack / src / utils / hh_logger.ml
blob9673244b0949f1f66e91dc60ca14fa47ca3eb201
1 (**
2 * Copyright (c) 2015, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the "hack" directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
9 *)
11 open Utils
13 let log_raw s =
14 let open Unix in
15 let tm = localtime (time ()) in
16 let year = tm.tm_year + 1900 in
17 let time_str = spf "[%d-%02d-%02d %02d:%02d:%02d]"
18 year (tm.tm_mon + 1) tm.tm_mday tm.tm_hour tm.tm_min tm.tm_sec in
19 Printf.eprintf "%s %s%!" time_str s
21 (* wraps log_raw in order to take a format string & add a newline *)
22 let log fmt = Printf.ksprintf log_raw (fmt^^"\n")
24 let log_duration name t =
25 log_raw (name ^ ": ");
26 let t2 = Unix.gettimeofday() in
27 Printf.eprintf "%f\n%!" (t2 -. t);