| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/LogEvent.R |
| 3 |
\name{as.data.frame.LogEvent} |
| 4 |
\alias{as.data.frame.LogEvent} |
| 5 |
\alias{as.data.table.LogEvent} |
| 6 |
\alias{as_tibble.LogEvent} |
| 7 |
\title{Coerce LogEvents to Data Frames} |
| 8 |
\usage{ |
| 9 |
\method{as.data.frame}{LogEvent}( |
| 10 |
x, |
| 11 |
row.names = NULL, |
| 12 |
optional = FALSE, |
| 13 |
stringsAsFactors = FALSE, |
| 14 |
..., |
| 15 |
box_if = function(.) !(is.atomic(.) && identical(length(.), 1L)), |
| 16 |
cols_expand = NULL |
| 17 |
) |
| 18 |
|
| 19 |
as.data.table.LogEvent( |
| 20 |
x, |
| 21 |
..., |
| 22 |
box_if = function(.) !(is.atomic(.) && identical(length(.), 1L)), |
| 23 |
cols_expand = "msg" |
| 24 |
) |
| 25 |
|
| 26 |
as_tibble.LogEvent( |
| 27 |
x, |
| 28 |
..., |
| 29 |
box_if = function(.) !(is.atomic(.) && identical(length(.), 1L)), |
| 30 |
cols_expand = "msg" |
| 31 |
) |
| 32 |
} |
| 33 |
\arguments{ |
| 34 |
\item{x}{any \R object.} |
| 35 |
|
| 36 |
\item{row.names}{\code{NULL} or a character vector giving the row |
| 37 |
names for the data frame. Missing values are not allowed.} |
| 38 |
|
| 39 |
\item{optional}{currently ignored and only included for compatibility.} |
| 40 |
|
| 41 |
\item{stringsAsFactors}{\code{logical} scalar: should \code{character} vectors be |
| 42 |
converted to factors? Defaults to \code{FALSE} (as opposed to |
| 43 |
\code{\link[base:as.data.frame]{base::as.data.frame()}}) and is only included for compatibility.} |
| 44 |
|
| 45 |
\item{...}{passed on to \code{data.frame()}} |
| 46 |
|
| 47 |
\item{box_if}{a \code{function} that returns \code{TRUE} or \code{FALSE} to determine |
| 48 |
which values are to be boxed (i.e. placed as single elements in a list |
| 49 |
column). See example} |
| 50 |
|
| 51 |
\item{cols_expand}{\code{character} vector. Columns to \emph{not} box (even if |
| 52 |
\code{box_if()} returns \code{TRUE}). Vectors in these columns will result in multiple |
| 53 |
rows in the result (rather than a single list-column row). This defaults to |
| 54 |
\code{"msg"} for vectorized logging over the log message.} |
| 55 |
} |
| 56 |
\description{ |
| 57 |
Coerce LogEvents to \code{data.frames}, \code{\link[data.table:data.table]{data.tables}}, |
| 58 |
or \code{\link[tibble:tibble]{tibbles}}. |
| 59 |
} |
| 60 |
\examples{ |
| 61 |
lg <- get_logger("test") |
| 62 |
lg$info("lorem ipsum") |
| 63 |
as.data.frame(lg$last_event) |
| 64 |
|
| 65 |
lg$info("LogEvents can store any custom log values", df = iris) |
| 66 |
as.data.frame(lg$last_event) |
| 67 |
head(as.data.frame(lg$last_event)$df[[1]]) |
| 68 |
|
| 69 |
# how boxing works |
| 70 |
|
| 71 |
# by default non-scalars are boxed |
| 72 |
lg$info("letters", letters = letters) |
| 73 |
as.data.frame(lg$last_event) |
| 74 |
|
| 75 |
# this behaviour can be modified by supplying a custom boxing function |
| 76 |
as.data.frame(lg$last_event, box_if = function(.) FALSE) |
| 77 |
as.data.frame(lg$last_event, cols_expand = "letters") |
| 78 |
|
| 79 |
# The `msg` argument of a log event is always vectorized |
| 80 |
lg$info(c("a vectorized", "log message")) |
| 81 |
as.data.frame(lg$last_event) |
| 82 |
|
| 83 |
lg$config(NULL) |
| 84 |
} |
| 85 |
\seealso{ |
| 86 |
\link[data.table:data.table]{data.table::data.table}, \link[tibble:tibble]{tibble::tibble} |
| 87 |
} |