1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374(*********************************************************************************)(* OCaml-LDP *)(* *)(* Copyright (C) 2016-2023 Institut National de Recherche en Informatique *)(* et en Automatique. All rights reserved. *)(* *)(* This program is free software; you can redistribute it and/or modify *)(* it under the terms of the GNU Lesser General Public License version *)(* 3 as published by the Free Software Foundation. *)(* *)(* 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 General Public License for more details. *)(* *)(* You should have received a copy of the GNU 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 *)(* *)(* Contact: Maxence.Guesdon@inria.fr *)(* *)(*********************************************************************************)(** *)letsrc=Logs.Src.create~doc:"log of the Ldp library""ldp"leterrf=Logs.err~srcfletwarnf=Logs.warn~srcfletinfof=Logs.info~srcfletdebugf=Logs.debug~srcfleterr_lwtf=Logs_lwt.err~srcfletwarn_lwtf=Logs_lwt.warn~srcfletinfo_lwtf=Logs_lwt.info~srcfletdebug_lwtf=Logs_lwt.debug~srcfletbad_log_levels=Printf.sprintf"Bad log level value: %S"sletlevel_of_strings=letopenLogsinmatchString.lowercase_asciiswith"app"|"0"->Logs.App|"error"|"1"->Error|"warning"|"2"->Warning|"info"|"3"->Info|"debug"|"4"->Debug|_->failwith(bad_log_levels)letstring_of_level=function|Logs.App->"app"|Error->"error"|Warning->"warning"|Info->"info"|Debug->"debug"letlevel_wrapper=letto_json?with_docl=`String(string_of_levell)inletfrom_json?(def=Logs.App)=function|`Strings->(trylevel_of_stringswithFailuremsg->err(funm->m"%s"msg);def)|json->err(funm->m"%s"(bad_log_level(Yojson.Safe.to_stringjson)));definletw=Ocf.Wrapper.maketo_jsonfrom_jsoninOcf.Wrapper.optionwletlog_level=Ocf.option~cb:(Logs.Src.set_levelsrc)level_wrapperNone