123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113(**************************************************************************)(* This file is part of the Codex semantics library. *)(* *)(* Copyright (C) 2013-2025 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* 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, version 2.1. *)(* *)(* It 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. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file LICENSE). *)(* *)(**************************************************************************)typecategory=stringletregister_categoryx=xmoduletypeS=sigvalresult:('a,Format.formatter,unit)format->'avalwarning:('a,Format.formatter,unit)format->'avalerror:('a,Format.formatter,unit)format->'avalfeedback:('a,Format.formatter,unit)format->'avalperformance_warning:('a,Format.formatter,unit)format->'avalimprecision_warning:('a,Format.formatter,unit)format->'a(* val debug: ?level:int -> ?category:string -> ('a, Format.formatter, unit) format -> 'a *)valfatal:('a,Format.formatter,unit,'b)format4->'aendmoduleDefault:S=structletlogwithx=Format.kfprintf(funfmt->Format.pp_print_newlinefmt();Format.pp_print_flushfmt())Format.err_formatterx;;letwarning=logwithleterror=logwithletresult=logwithlet_alarma=logwith"%s"(Operator.Alarm.showa)letfeedback=logwithletperformance_warning=logwithletimprecision_warning=logwithletfatalstr=Format.kfprintf(funfmt->Format.pp_print_newlinefmt();Format.pp_print_flushfmt();assertfalse)Format.err_formatterstr;;endletr=ref(moduleDefault:S);;letregister(moduleX:S)=r:=(moduleX);;(* Does not print anything (except fatal errors). *)moduleNull:S=structletlogwithx=Format.ikfprintf(funfmt->Format.pp_print_newlinefmt();Format.pp_print_flushfmt())Format.err_formatterx;;letwarning=logwithleterror=logwithletresult=logwithletfeedback=logwithletperformance_warning=logwithletimprecision_warning=logwithletfatalstr=Format.kfprintf(funfmt->Format.pp_print_newlinefmt();Format.pp_print_flushfmt();assertfalse)Format.err_formatterstr;;endmoduleDynamic:S=struct(* let register_category = let module X:S = (val !r) in X.register_category;; *)letwarningfmt=letmoduleX:S=(val!r)inX.warningfmt;;leterrorfmt=letmoduleX:S=(val!r)inX.errorfmt;;letresultfmt=letmoduleX:S=(val!r)inX.resultfmt;;letperformance_warningfmt=letmoduleX:S=(val!r)inX.performance_warningfmt;;letimprecision_warningfmt=letmoduleX:S=(val!r)inX.imprecision_warningfmt;;(* let debug ?level ?category fmt = *)(* let _ = level and _ = category in *)(* let module X:S = (val !r) in X.debug ?category fmt;; *)letfatalfmt=letmoduleX:S=(val!r)inX.fatalfmt;;letfeedbackfmt=letmoduleX:S=(val!r)inX.feedbackfmt;;endmoduleTracelog_Instance=Tracelog.Make(structletcategory="codex"end);;moduleTracelog_Log:S=structletresultfmt=Format.kasprintf(funstr->Tracelog_Instance.notice(funm->m"%s"str))fmt;;letfeedbackfmt=Format.kasprintf(funstr->Tracelog_Instance.info(funm->m"%s"str))fmt;;leterrorfmt=Format.kasprintf(funstr->Tracelog_Instance.error(funm->m"%s"str))fmt;;letwarningfmt=Format.kasprintf(funstr->Tracelog_Instance.warning(funm->m"%s"str))fmt;;letperformance_warning=warningletimprecision_warning=warningletfatalfmt=Format.kasprintf(funstr->Tracelog_Instance.fatal(funm->m"%s"str))fmt;;endmoduleUsed=DynamicincludeUsed