File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 (libraries
55 astring
66 cmdliner
7- fmt
8- ptime.clock
97 uuidm
108 xapi-consts
119 xapi-datamodel
Original file line number Diff line number Diff line change @@ -34,13 +34,10 @@ let internal_role_local_root = "_local_root_"
3434
3535(* the output of this function is used as input by the automatic tests *)
3636let writer_csv static_permissions_roles =
37- let now =
38- let now = Ptime_clock. now () in
39- let str = Fmt. str " %a" Ptime. (pp_rfc3339 ~frac_s: 3 ~tz_offset_s: 0 () ) now in
40- (* remove separators between Year, Month, and Day; to keep old logging format *)
41- Astring.String. filter (function '-' -> false | _ -> true ) str
42- in
43- Printf. sprintf " %s,PERMISSION/ROLE,%s\n " now
37+ Printf. sprintf " %s,PERMISSION/ROLE,%s\n "
38+ (let t = Debug. gettimestring () in
39+ String. sub t 0 (String. length t - 1 )
40+ )
4441 (* role titles are ordered by roles in roles_all *)
4542 (List. fold_left (fun rr r -> rr ^ r ^ " ," ) " " Datamodel_roles. roles_all)
4643 ^ List. fold_left
Original file line number Diff line number Diff line change @@ -74,8 +74,13 @@ let tasks : task ThreadLocalTable.t = ThreadLocalTable.make ()
7474let names : string ThreadLocalTable.t = ThreadLocalTable. make ()
7575
7676let gettimestring () =
77- let now = Ptime_clock. now () in
78- Fmt. str " %a|" Ptime. (pp_rfc3339 ~frac_s: 3 ~tz_offset_s: 0 () ) now
77+ let time = Unix. gettimeofday () in
78+ let tm = Unix. gmtime time in
79+ let msec = time -. floor time in
80+ Printf. sprintf " %d%.2d%.2dT%.2d:%.2d:%.2d.%.3dZ|" (1900 + tm.Unix. tm_year)
81+ (tm.Unix. tm_mon + 1 ) tm.Unix. tm_mday tm.Unix. tm_hour tm.Unix. tm_min
82+ tm.Unix. tm_sec
83+ (int_of_float (1000.0 *. msec))
7984
8085(* * [escape str] efficiently escapes non-printable characters and in addition
8186 the backslash character. The function is efficient in the sense that it will
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ val set_remote_context : string option -> unit
3434
3535module type BRAND = sig val name : string end
3636
37+ val gettimestring : unit -> string
38+ (* * The current time of day in a format suitable for logging *)
39+
3740val set_facility : Syslog .facility -> unit
3841(* * Set the syslog facility that will be used by this program. *)
3942
Original file line number Diff line number Diff line change 1010 fmt
1111 mtime
1212 logs
13- ptime
14- ptime.clock
1513 threads.posix
1614 unix
1715 xapi-log.backtrace
You can’t perform that action at this time.
0 commit comments