Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file lwt_log_js.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139(* Js_of_ocaml library
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2014 Hugo Heuzard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)includeLwt_log_coreopenJs_of_ocamlopen!Importletjs_val=Lwt.new_key()letconsole=make~close:(fun_->Lwt.return_unit)~output:(funsectionlevellogs->letstr=Js.string(Printf.sprintf"[%s] %s"(Section.namesection)(String.concat"\n"logs))in(matchlevel,Lwt.getjs_valwith|Debug,None->Firebug.console##debugstr|Debug,Somev->Firebug.console##debug_2strv|Info,None|Notice,None->Firebug.console##infostr|Info,Somev|Notice,Somev->Firebug.console##info_2strv|Warning,None->Firebug.console##warnstr|Warning,Somev->Firebug.console##warn_2strv|Error,None|Fatal,None->Firebug.console##errorstr|Error,Somev|Fatal,Somev->Firebug.console##error_2strv);Lwt.return_unit)letlog?inspect?exn?section?location?logger~levelmessage=letinspect=matchinspectwith|None->None|Somev->Some(Obj.reprv)inLwt.with_valuejs_valinspect(fun()->log?exn?section?location?logger~levelmessage)letlog_f?inspect?exn?section?location?logger~levelformat=Printf.ksprintf(log?inspect?exn?section?location?logger~level)formatletign_log?inspect?exn?section?location?logger~levelmessage=tryignore(log?inspect?exn?section?location?logger~levelmessage)with_->()letign_log_f?inspect?exn?section?location?logger~levelformat=Printf.ksprintf(ign_log?inspect?exn?section?location?logger~level)formatletdebug?inspect?exn?section?location?loggermsg=log?inspect?exn?section?location?logger~level:Debugmsgletdebug_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(debug?inspect?exn?section?location?logger)fmtletinfo?inspect?exn?section?location?loggermsg=log?inspect?exn?section?location?logger~level:Infomsgletinfo_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(info?inspect?exn?section?location?logger)fmtletnotice?inspect?exn?section?location?loggermsg=log?inspect?exn?section?location?logger~level:Noticemsgletnotice_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(notice?inspect?exn?section?location?logger)fmtletwarning?inspect?exn?section?location?loggermsg=log?inspect?exn?section?location?logger~level:Warningmsgletwarning_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(warning?inspect?exn?section?location?logger)fmtleterror?inspect?exn?section?location?loggermsg=log?inspect?exn?section?location?logger~level:Errormsgleterror_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(error?inspect?exn?section?location?logger)fmtletfatal?inspect?exn?section?location?loggermsg=log?inspect?exn?section?location?logger~level:Fatalmsgletfatal_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(fatal?inspect?exn?section?location?logger)fmtletign_debug?inspect?exn?section?location?loggermsg=ign_log?inspect?exn?section?location?logger~level:Debugmsgletign_debug_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(ign_debug?inspect?exn?section?location?logger)fmtletign_info?inspect?exn?section?location?loggermsg=ign_log?inspect?exn?section?location?logger~level:Infomsgletign_info_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(ign_info?inspect?exn?section?location?logger)fmtletign_notice?inspect?exn?section?location?loggermsg=ign_log?inspect?exn?section?location?logger~level:Noticemsgletign_notice_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(ign_notice?inspect?exn?section?location?logger)fmtletign_warning?inspect?exn?section?location?loggermsg=ign_log?inspect?exn?section?location?logger~level:Warningmsgletign_warning_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(ign_warning?inspect?exn?section?location?logger)fmtletign_error?inspect?exn?section?location?loggermsg=ign_log?inspect?exn?section?location?logger~level:Errormsgletign_error_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(ign_error?inspect?exn?section?location?logger)fmtletign_fatal?inspect?exn?section?location?loggermsg=ign_log?inspect?exn?section?location?logger~level:Fatalmsgletign_fatal_f?inspect?exn?section?location?loggerfmt=Printf.ksprintf(ign_fatal?inspect?exn?section?location?logger)fmt(*let raise_error ?inspect ?exn ?section ?location ?logger msg =
Lwt.ignore_result (log ?inspect ?exn ?section ?location ?logger ~level:Error msg);
failwith msg *)(*let raise_error_f ?inspect ?exn ?section ?location ?logger fmt =
Printf.ksprintf (raise_error ?inspect ?exn ?section ?location ?logger) fmt *)