Skip to content
This repository
tag: v768
Fetching contributors…

Cannot retrieve contributors at this time

file 48 lines (42 sloc) 2.14 kb
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
##register debug: string, 'a -> void
##register info: string, 'a -> void
##register notice: string, 'a -> void
##register log\ notice: string, 'a -> void
##register warning: string, 'a -> void
##register error: string, 'a -> void
##register fatal\ critical: string, 'a -> void

let error topic x = Logger.error "%s %s" topic (DebugPrint.simple_print x)
let warning topic x = Logger.warning "%s %s" topic (DebugPrint.simple_print x)
let notice topic x = Logger.notice "%s %s" topic (DebugPrint.simple_print x)
let info topic x = Logger.info "%s %s" topic (DebugPrint.simple_print x)
let debug topic x = Logger.debug "%s %s" topic (DebugPrint.simple_print x)
let emergency topic x = Logger.emergency "%s %s" topic (DebugPrint.simple_print x)
let alert topic x = Logger.alert "%s %s" topic (DebugPrint.simple_print x)
let critical topic x = Logger.critical "%s %s" topic (DebugPrint.simple_print x)

(**
int is in microseconds
event are log in event.log
[event time src properties json_content]
*)
##register event: int,string,string,string -> void
let event =
  let logger =
    let file = Logger.make_rotating_destination ~days:1 "event" in
    let dest = Logger.empty_logger () in
    let _ = Logger.add_destination dest file in
    dest
  in
  fun time src properties content -> Logger.log_access ~logger ~priority:Logger.Emergency "%d %s %s %s" time src properties content (* time display desactivated *)
Something went wrong with that request. Please try again.