123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245open!Coreopen!Async_kernelopen!Import(** An interface for singleton logs. *)moduletypeS=sigvallog:Log.tLazy.t(** Make a copy of this log, with potentially some settings changed, or potentially
extra tags added to each line. *)valcopy:?level:Level.t->?on_error:[`CallofError.t->unit|`Raise]->?output:Output.tlist->?extra_tags:(string*string)list->unit->Log.tvallevel:unit->Level.tvalset_level:Level.t->unitvalset_output:Output.tlist->unitvalget_output:unit->Output.tlistvalset_on_error:[`Raise|`CallofError.t->unit]->unitvalget_time_source:unit->Synchronous_time_source.tvalset_time_source:[>read]Synchronous_time_source.T1.t->unitmoduleTransform:sigtypetvalappend':(Message_event.t->Message_event.toption)->tvalprepend':(Message_event.t->Message_event.toption)->tvalappend:(Message_event.t->Message_event.t)->unitvalprepend:(Message_event.t->Message_event.t)->unitvalremove_exn:t->unitendvalhas_transform:unit->boolvalclear_transforms:unit->unitvalset_transform:(Message_event.t->Message_event.toption)option->unit[@@deprecated"[since 2024-10] Use [Log.Global.Transform.add] instead"]valget_transform:unit->(Message_event.t->Message_event.toption)option[@@deprecated"[since 2024-10] Getting the transform is not supported but transforms may cleared \
with [Log.Global.clear_transforms] or added to with [Log.Global.Transform.add]"]valadd_tags:tags:(string*string)list->unitvalwould_log:Level.toption->bool(** Sets the global log level via a flag, if provided.
If [default] is not provided, the existing log level will be unchanged if the flag
is not provided. *)valset_level_via_param:?default:Level.t->unit->unitCommand.Param.tvalraw:?time:Time_float.t->?tags:(string*string)list->('a,unit,string,unit)format4->'avalinfo:?time:Time_float.t->?tags:(string*string)list->('a,unit,string,unit)format4->'avalwarn:?time:Time_float.t->?tags:(string*string)list->('a,unit,string,unit)format4->'avalerror:?time:Time_float.t->?tags:(string*string)list->('a,unit,string,unit)format4->'avaldebug:?time:Time_float.t->?tags:(string*string)list->('a,unit,string,unit)format4->'a(** [flushed ()] waits for messages that have already been delivered to the global log.
Logs written via portable functions, such as [Log.Global.Portable.info], may still
be waiting in the portable enqueue path and are not included until they have been
delivered to the global log. *)valflushed:unit->unitDeferred.t(** Generalized printf-style logging. *)valprintf:?level:Level.t->?time:Time_float.t->?tags:(string*string)list->('a,unit,string,unit)format4->'a(** Sexp logging for messages at each log level or raw (no level) messages. Raw messages
still include a timestamp *)valraw_s:?time:Time_float.t->?tags:(string*string)list->Sexp.t->unitvalinfo_s:?time:Time_float.t->?tags:(string*string)list->Sexp.t->unitvalwarn_s:?time:Time_float.t->?tags:(string*string)list->Sexp.t->unitvalerror_s:?time:Time_float.t->?tags:(string*string)list->Sexp.t->unitvaldebug_s:?time:Time_float.t->?tags:(string*string)list->Sexp.t->unit(** Generalized sexp-style logging. *)valsexp:?level:Level.t->?time:Time_float.t->?tags:(string*string)list->Sexp.t->unit(** Log a string directly. *)valstring:?level:Level.t->?time:Time_float.t->?tags:(string*string)list->string->unitvalstructured_message:?level:Level.t->?time:Time_float.t->?tags:(string*string)list->Message_data.t->Message_source.t->unitvalenqueue_structured_message:?level:Level.t->?time:Time_float.t->?tags:(string*string)list->Message_data.t->Message_source.t->unit@@portable(** Log a pre-created message. *)valmessage:Message.t->unitvalmessage_event:Message_event.t->unit(** [surround t message f] logs [message] and a UUID once before calling [f] and again
after [f] returns or raises. If [f] raises, the second message will include the
exception, and [surround] itself will re-raise the exception tagged with [message].
[on_subsequent_errors] is passed to the internal monitor as [rest] argument. As
usual, the logging happens only if [level] exceeds the minimum level of [t]. *)valsurround_s:on_subsequent_errors:[`Callofexn->unit|`Log|`Raise]->?level:Level.t->?time:Time_float.t->?tags:(string*string)list->Sexp.t->(unit->'aDeferred.t)->'aDeferred.tvalsurroundf:on_subsequent_errors:[`Callofexn->unit|`Log|`Raise]->?level:Level.t->?time:Time_float.t->?tags:(string*string)list->('a,unit,string,(unit->'bDeferred.t)->'bDeferred.t)format4->'amoduleFor_testing:sig(** Change the global log so that it
1. Writes synchronously.
2. By default only prints the bodies of messages to stdout, discarding any
information about tags, levels, or timestamps. Use optional time, tags and
level arguments to print required metadata information.
[map_output] can be used to transform messages before they make it to stdout; by
default it is [Fn.id].
(This is equivalent to:
[Log.Global.set_output [ Log.For_testing.create_output ~map_output ~time ~tags ~level () ]]) *)valuse_test_output:?map_output:(string->string)->?time:[`Keep|`Omit]->?tags:[`Keep|`Omit]->?level:[`Keep|`Omit]->unit->unitend(** Used internally by other [Async] libraries.
There are two locations in [Async], [Async_command] and
[Async_unix.Shutdown.shutdown_on_unhandled_exn], that have logic to catch unhandled
exceptions and log them before exiting. Normally, they write these shutdown logs to
stderr, but sometimes it's desirable to additionally write to select log outputs.
[log_error] is used by the two locations to log to these outputs at shutdown.
[register_error_output_name] allows downstream libraries to opt their outputs into
shutdown logging.
[Async_command] wraps its command's [main] function in a [try_with], and calls
[log_error] on error.
[shutdown_on_unhandled_exn], which is usually used with programs that directly call
[Scheduler.go], catches exceptions with [Monitor.detach_and_iter_errors]; caught
exceptions are sent to a mutable hook that [Async_log.assign_top_level_logs] sets
with [Shutdown.set_shutdown_on_unhandled_exn_logger]. *)moduleFor_async_shutdown:sigvalregister_error_output_name:Output_name.t->unit[@@alertprivate_async_log_function"This function is meant for the specific use case of logging from \
[Async_command] and [Async_unix] at shutdown without double-writing to stderr. \
Please speak to async log devs if you need to use it for something else."]vallog_error:?time:Time_float.t->?tags:(string*string)list->('a,unit,string,unit)format4->'a[@@alertprivate_async_log_function"This function is meant for the specific use case of logging from \
[Async_command] and [Async_unix] at shutdown without double-writing to stderr. \
Please speak to async log devs if you need to use it for something else."]endmodulePrivate:sig(** Returns the portable global log handle once the lazy global log has been forced. *)valcurrent_published_log:unit->Log.toption@@portableendendmoduletypeGlobal=sigmoduletypeS=S(** This function can be called to generate logging modules with the [Log.t] lazily
instantiated, and prepopulated in the arguments. *)moduleMake():S(** This module provides functions like [Global.sexp] which logs without needing to
provide a [Log.t]. At this point, it's recommended to use [ppx_log] instead. *)includeSend