| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/basic_config.R |
| 3 |
\name{basic_config} |
| 4 |
\alias{basic_config} |
| 5 |
\title{Basic Setup for the Logging System} |
| 6 |
\usage{ |
| 7 |
basic_config( |
| 8 |
file = NULL, |
| 9 |
fmt = "\%L [\%t] \%m", |
| 10 |
timestamp_fmt = "\%Y-\%m-\%d \%H:\%M:\%OS3", |
| 11 |
threshold = "info", |
| 12 |
appenders = NULL, |
| 13 |
console = if (is.null(appenders)) "all" else FALSE, |
| 14 |
console_fmt = "\%L [\%t] \%m \%f", |
| 15 |
console_timestamp_fmt = "\%H:\%M:\%OS3", |
| 16 |
console_connection = NULL, |
| 17 |
memory = FALSE |
| 18 |
) |
| 19 |
} |
| 20 |
\arguments{ |
| 21 |
\item{file}{\code{character} scalar: If not \code{NULL} a \link{AppenderFile} will be |
| 22 |
created that logs to this file. If the filename ends in \code{.jsonl}, the |
| 23 |
Appender will be set up to use the \href{https://jsonlines.org/}{JSON Lines} |
| 24 |
format instead of plain text (see \link{AppenderFile} and \link{AppenderJson}).} |
| 25 |
|
| 26 |
\item{fmt}{\code{character} scalar: Format to use if \code{file} is supplied and not a |
| 27 |
\code{.jsonl} file. If \code{NULL} it defaults to \code{"\%L [\%t] \%m"} (see |
| 28 |
\link{format.LogEvent})} |
| 29 |
|
| 30 |
\item{timestamp_fmt}{see \code{\link[=format.POSIXct]{format.POSIXct()}}} |
| 31 |
|
| 32 |
\item{threshold}{\code{character} or \code{integer} scalar. The minimum \link[=log_levels]{log level} that should be processed by the root logger.} |
| 33 |
|
| 34 |
\item{appenders}{a single \link{Appender} or a list thereof.} |
| 35 |
|
| 36 |
\item{console}{\code{logical} scalar or a \code{threshold} (see above). Add an appender |
| 37 |
logs to the console (i.e. displays messages in an interactive R session)} |
| 38 |
|
| 39 |
\item{console_fmt}{\code{character} scalar: like \code{fmt} but used for console output} |
| 40 |
|
| 41 |
\item{console_timestamp_fmt}{\code{character} scalar: like \code{timestamp_fmt} but |
| 42 |
used for console output} |
| 43 |
|
| 44 |
\item{console_connection}{see \code{\link[=cat]{cat()}} \code{file} argument.} |
| 45 |
|
| 46 |
\item{memory}{\code{logical} scalar. or a \code{threshold} (see above). Add an Appender |
| 47 |
that logs to a memory buffer, see also \code{\link[=show_log]{show_log()}} and \link{AppenderBuffer}} |
| 48 |
} |
| 49 |
\value{ |
| 50 |
the \code{root} Logger (lgr) |
| 51 |
} |
| 52 |
\description{ |
| 53 |
A quick and easy way to configure the root logger. This is less powerful |
| 54 |
then using \code{lgr$config()} or \verb{lgr$set_*()} (see \link{Logger}), but reduces the |
| 55 |
most common configurations to a single line of code. |
| 56 |
} |
| 57 |
\examples{ |
| 58 |
# log to a file |
| 59 |
basic_config(file = tempfile()) |
| 60 |
unlink(lgr$appenders$file$file) # cleanup |
| 61 |
|
| 62 |
basic_config(file = tempfile(fileext = "jsonl")) |
| 63 |
unlink(lgr$appenders$file$file) # cleanup |
| 64 |
|
| 65 |
# log debug messages to a memory buffer |
| 66 |
basic_config(threshold = "all", memory = "all", console = "info") |
| 67 |
lgr$info("an info message") |
| 68 |
lgr$debug("a hidden message") |
| 69 |
show_log() |
| 70 |
|
| 71 |
# reset to default config |
| 72 |
basic_config() |
| 73 |
} |