Skip to content

Logging

Attila Szabo edited this page Dec 22, 2023 · 1 revision

Configuration

  • In Aardvark.Base there is the static class Report which is used to log something and logging can be configured
  • The log output is defined by Report.Targets which is a MultiLogTarget and has a ConsoleLogTarget and LogTarget (log file) as default
  • Report.LogFileName sets the file for the LogTarget and the default is "Aardvark.log" right next to the startup location (needs to be set before first log output)
  • Report.Verbosity lets you control the verbosity of ConsoleLogTarget (in general each log target has its own verbosity)
  • You can add/remove targets as you like
  • A target needs to implement ILogTarget to for example redirect the Aardvark logging to another output

Usage C#

  • Report.Line Report.Warn Report.Error are the most common functions found in: Report.cs
  • They work like String.Format where you can pass a format string and an arbitrary list of arguments
  • A log line starts with a thread identifier
  • Report.Value allows to log variable values more conveniently
  • Report.Begin Report.End allows to group/indent logging in between (e.g. by Report.Line)
  • Report.BeginTimed Report.EndTimed or Report.End (works both) also measure the timing of the block
  • Report.BeginTimedNoLog will only report the timing using the message in Report.End, this avoids interleaved outputs in multithreading
  • All report functions have an optional verbosity, in case you use Begin/End be careful to make sure they are identical
  • Advanced features Report.Progress Report.Job

Usage F#

  • There are F# style counterparts of Report.* the Log module: Logging.fs
  • Log.line Log.warn Log.error
  • Log.start Log.startTimed Log.stop
Clone this wiki locally