From 93fe38bbc3c439802bfa039d4bc3e2e263032899 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Tue, 14 Apr 2020 07:42:29 -0700 Subject: [PATCH] [logging] replicate internal errors in scuba Summary: Log all internal errors to scuba as well. Reviewed By: jvillard Differential Revision: D21017432 fbshipit-source-id: 42ef2e910 --- infer/src/base/Logging.ml | 13 +++++++++++++ infer/src/base/ScubaLogging.mli | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/infer/src/base/Logging.ml b/infer/src/base/Logging.ml index 53c55887d..3f67c0833 100644 --- a/infer/src/base/Logging.ml +++ b/infer/src/base/Logging.ml @@ -265,6 +265,16 @@ let debug kind level fmt = log ~to_console:false ~to_file debug_file_fmts fmt +(** log to scuba as well as in the original logger *) +let wrap_in_scuba_log ~label ~log fmt = + let wrapper message = + ScubaLogging.log_message ~label ~message ; + (* [format_of_string] is there to satisfy the type checker *) + log (format_of_string "%s") message + in + F.kasprintf wrapper fmt + + let result fmt = log ~to_console:true result_file_fmts fmt let environment_info fmt = log ~to_console:false environment_info_file_fmts fmt @@ -275,6 +285,9 @@ let external_error fmt = log ~to_console:true external_error_file_fmts fmt let internal_error fmt = log ~to_console:true internal_error_file_fmts fmt +(* mask original function and replicate log in scuba *) +let internal_error fmt = wrap_in_scuba_log ~label:"internal_error" ~log:internal_error fmt + (** Type of location in ml source: __POS__ *) type ocaml_pos = string * int * int * int diff --git a/infer/src/base/ScubaLogging.mli b/infer/src/base/ScubaLogging.mli index 1bcbe8210..47cfdcd49 100644 --- a/infer/src/base/ScubaLogging.mli +++ b/infer/src/base/ScubaLogging.mli @@ -19,7 +19,6 @@ val log_count : label:string -> value:int -> unit (** Log anything that can be counted. Events will be prefixed with ["count."] *) val log_message : label:string -> message:string -> unit - [@@warning "-32"] (** Log a [string]. Event is prefixed with ["msg."] *) val execute_with_time_logging : string -> (unit -> 'a) -> 'a