123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)openError_monadtypet={active_sinks:Uri.tlist}letmake_section_prefix~patternlevel=Format.sprintf"%s:%s"pattern(Internal_event.Level.to_stringlevel)letmake_config_uri?level?daily_logs?create_dirs?format?chmod?with_pid?colors?fresh?(section_prefixes=[])kind=letscheme,path=matchkindwith|`Stdout->("file-descriptor-stdout",None)|`Stderr->("file-descriptor-stderr",None)|`Pathpath->("file-descriptor-path",Somepath)|`Null->("file-descriptor-null",None)|`Syslogstr->("file-descriptor-"^str,None)inletaddpropstrvconf=matchvwithSomec->(prop,[strc])::conf|None->confinletmake_section_prefixessp=List.map(fun(pattern,lvl)->make_section_prefix~patternlvl)sp|>List.map(funp->("section-prefix",[p]))inletbool=Format.sprintf"%B"inUri.make?path~scheme~query:(make_section_prefixessection_prefixes|>add"format"Fun.idformat|>add"level-at-least"Internal_event.Level.to_stringlevel|>add"create-dirs"boolcreate_dirs|>add"daily-logs"string_of_intdaily_logs|>add"fresh"boolfresh|>add"colors"boolcolors|>add"chmod"string_of_intchmod|>add"with_pid"boolwith_pid)()letshort_stdout_uri=make_config_uri~format:"pp-short"~level:Notice`Stdoutletstdout={active_sinks=[short_stdout_uri]}letempty={active_sinks=[]}letis_empty{active_sinks}=active_sinks=[]letmake_customactive_sinks={active_sinks}letencoding=letopenData_encodinginletobject_1key_name=obj1(dftkey_name~description:"List of URIs to activate/configure sinks."(liststring)[])inunion[case~title:"Active-Sinks"~description:"List of sinks to make sure are activated."(Tag0)(object_1"active_sinks")(fun{active_sinks}->Some(List.mapUri.to_stringactive_sinks))(funactive_sinks->{active_sinks=List.mapUri.of_stringactive_sinks});case~title:"Active-Sinks-Deprecated"~description:"List of sinks to make sure are activated, deprecated \
backwards-compatibility encoding."(Tag1)(object_1"activate")(fun{active_sinks=_}->None)(* (fun {active_sinks} -> Some (List.map Uri.to_string active_sinks)) *)(funactive_sinks->{active_sinks=List.mapUri.of_stringactive_sinks});]letapply{active_sinks}=List.iter_esInternal_event.All_sinks.activateactive_sinksletreapplyconfig=letopenLwt_result_syntaxinletexceptu=u=short_stdout_uriinlet*()=Internal_event.All_sinks.close~except()inapplyconfig