| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/event_list.R |
| 3 |
\name{event_list} |
| 4 |
\alias{event_list} |
| 5 |
\alias{as_event_list} |
| 6 |
\alias{as_event_list.list} |
| 7 |
\alias{as_event_list.LogEvent} |
| 8 |
\alias{as_event_list.data.frame} |
| 9 |
\alias{as.data.table.event_list} |
| 10 |
\alias{as.data.frame.event_list} |
| 11 |
\title{A List of LogEvents} |
| 12 |
\usage{ |
| 13 |
event_list(...) |
| 14 |
|
| 15 |
as_event_list(x, ...) |
| 16 |
|
| 17 |
\method{as_event_list}{list}(x, ..., scalarize = FALSE) |
| 18 |
|
| 19 |
\method{as_event_list}{LogEvent}(x, ..., scalarize = FALSE) |
| 20 |
|
| 21 |
\method{as_event_list}{data.frame}(x, na.rm = TRUE, ...) |
| 22 |
|
| 23 |
as.data.table.event_list(x, na.rm = TRUE) |
| 24 |
|
| 25 |
\method{as.data.frame}{event_list}( |
| 26 |
x, |
| 27 |
row.names = NULL, |
| 28 |
optional = FALSE, |
| 29 |
stringsAsFactors = FALSE, |
| 30 |
na.rm = TRUE, |
| 31 |
... |
| 32 |
) |
| 33 |
} |
| 34 |
\arguments{ |
| 35 |
\item{...}{for \code{event} elements to be added to the list, for the \verb{as_*()} |
| 36 |
functions parameters passed on to methods.} |
| 37 |
|
| 38 |
\item{x}{any \code{R} object} |
| 39 |
|
| 40 |
\item{scalarize}{\code{logical} scalar. Turn \link{LogEvents} with non-scalar \code{msg} |
| 41 |
field into separate log events} |
| 42 |
|
| 43 |
\item{na.rm}{remove \code{NA} values before coercing a data.frame to an \code{event_list()}.} |
| 44 |
|
| 45 |
\item{row.names}{\code{NULL} or a character vector giving the row |
| 46 |
names for the data frame. Missing values are not allowed.} |
| 47 |
|
| 48 |
\item{optional}{currently ignored and only included for compatibility.} |
| 49 |
|
| 50 |
\item{stringsAsFactors}{\code{logical} scalar: should \code{character} vectors be |
| 51 |
converted to factors? Defaults to \code{FALSE} (as opposed to |
| 52 |
\code{\link[base:as.data.frame]{base::as.data.frame()}}) and is only included for compatibility.} |
| 53 |
} |
| 54 |
\value{ |
| 55 |
an \code{event_list()} and \code{as_event_list()} return a flat \code{list} |
| 56 |
of \link{LogEvents}. Nested lists get automatically flattened. |
| 57 |
|
| 58 |
\code{as.data.frame} and \code{as.data.table} return a \code{data.frame} or \code{data.table} |
| 59 |
respectively |
| 60 |
} |
| 61 |
\description{ |
| 62 |
An event_list is a class for \code{list()}s whose only elements are \link{LogEvents}. |
| 63 |
This structure is occasionally used internally in lgr (for example by |
| 64 |
\link{AppenderBuffer}) and can be useful for developers that want to write |
| 65 |
their own Appenders. |
| 66 |
} |
| 67 |
\details{ |
| 68 |
For convenience, \code{as.data.frame()} and \code{as.data.table()} methods |
| 69 |
exist for event lists. |
| 70 |
} |
| 71 |
\examples{ |
| 72 |
e <- LogEvent$new(level = 300, msg = "a", logger = lgr) |
| 73 |
as_event_list(e) |
| 74 |
as_event_list(c(e, e)) |
| 75 |
# nested lists get automatically unnested |
| 76 |
as_event_list(c(e, list(nested_event = e))) |
| 77 |
|
| 78 |
# scalarize = TRUE "unpacks" events with vector log messages |
| 79 |
e <- LogEvent$new(level = 300, msg = c("A", "B"), logger = lgr) |
| 80 |
as_event_list(e, scalarize = FALSE) |
| 81 |
as_event_list(e, scalarize = TRUE) |
| 82 |
|
| 83 |
} |
| 84 |
\seealso{ |
| 85 |
Other docs relevant for extending lgr: |
| 86 |
\code{\link{LogEvent}}, |
| 87 |
\code{\link{as_LogEvent}()}, |
| 88 |
\code{\link{standardize_threshold}()} |
| 89 |
} |
| 90 |
\concept{docs relevant for extending lgr} |