| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/Appender.R |
| 3 |
\name{AppenderConsole} |
| 4 |
\alias{AppenderConsole} |
| 5 |
\title{Log to the console} |
| 6 |
\description{ |
| 7 |
An Appender that outputs to the \R console. If you have the package |
| 8 |
\strong{crayon} installed log levels will be coloured by default |
| 9 |
(but you can modify this behaviour by passing a custom \link{Layout}). |
| 10 |
} |
| 11 |
\examples{ |
| 12 |
# create a new logger with propagate = FALSE to prevent routing to the root |
| 13 |
# logger. Please look at the section "Logger Hirarchies" in the package |
| 14 |
# vignette for more info. |
| 15 |
lg <- get_logger("test")$set_propagate(FALSE) |
| 16 |
|
| 17 |
lg$add_appender(AppenderConsole$new()) |
| 18 |
lg$add_appender(AppenderConsole$new( |
| 19 |
layout = LayoutFormat$new("[\%t] \%c(): [\%n] \%m", colors = getOption("lgr.colors")))) |
| 20 |
|
| 21 |
# Will output the message twice because we attached two console appenders |
| 22 |
lg$warn("A test message") |
| 23 |
lg$config(NULL) # reset config |
| 24 |
} |
| 25 |
\seealso{ |
| 26 |
\link{LayoutFormat} |
| 27 |
|
| 28 |
Other Appenders: |
| 29 |
\code{\link{Appender}}, |
| 30 |
\code{\link{AppenderBuffer}}, |
| 31 |
\code{\link{AppenderFile}}, |
| 32 |
\code{\link{AppenderFileRotating}}, |
| 33 |
\code{\link{AppenderFileRotatingDate}}, |
| 34 |
\code{\link{AppenderFileRotatingTime}}, |
| 35 |
\code{\link{AppenderTable}} |
| 36 |
} |
| 37 |
\concept{Appenders} |
| 38 |
\section{Super classes}{ |
| 39 |
\code{\link[lgr:Filterable]{lgr::Filterable}} -> \code{\link[lgr:Appender]{lgr::Appender}} -> \code{AppenderConsole} |
| 40 |
} |
| 41 |
\section{Methods}{ |
| 42 |
\subsection{Public methods}{ |
| 43 |
\itemize{ |
| 44 |
\item \href{#method-AppenderConsole-new}{\code{AppenderConsole$new()}} |
| 45 |
\item \href{#method-AppenderConsole-append}{\code{AppenderConsole$append()}} |
| 46 |
\item \href{#method-AppenderConsole-set_connection}{\code{AppenderConsole$set_connection()}} |
| 47 |
} |
| 48 |
} |
| 49 |
\if{html}{\out{ |
| 50 |
<details><summary>Inherited methods</summary> |
| 51 |
<ul> |
| 52 |
<li><span class="pkg-link" data-pkg="lgr" data-topic="Filterable" data-id="add_filter"><a href='../../lgr/html/Filterable.html#method-Filterable-add_filter'><code>lgr::Filterable$add_filter()</code></a></span></li> |
| 53 |
<li><span class="pkg-link" data-pkg="lgr" data-topic="Filterable" data-id="filter"><a href='../../lgr/html/Filterable.html#method-Filterable-filter'><code>lgr::Filterable$filter()</code></a></span></li> |
| 54 |
<li><span class="pkg-link" data-pkg="lgr" data-topic="Filterable" data-id="remove_filter"><a href='../../lgr/html/Filterable.html#method-Filterable-remove_filter'><code>lgr::Filterable$remove_filter()</code></a></span></li> |
| 55 |
<li><span class="pkg-link" data-pkg="lgr" data-topic="Filterable" data-id="set_filters"><a href='../../lgr/html/Filterable.html#method-Filterable-set_filters'><code>lgr::Filterable$set_filters()</code></a></span></li> |
| 56 |
<li><span class="pkg-link" data-pkg="lgr" data-topic="Appender" data-id="format"><a href='../../lgr/html/Appender.html#method-Appender-format'><code>lgr::Appender$format()</code></a></span></li> |
| 57 |
<li><span class="pkg-link" data-pkg="lgr" data-topic="Appender" data-id="set_layout"><a href='../../lgr/html/Appender.html#method-Appender-set_layout'><code>lgr::Appender$set_layout()</code></a></span></li> |
| 58 |
<li><span class="pkg-link" data-pkg="lgr" data-topic="Appender" data-id="set_threshold"><a href='../../lgr/html/Appender.html#method-Appender-set_threshold'><code>lgr::Appender$set_threshold()</code></a></span></li> |
| 59 |
</ul> |
| 60 |
</details> |
| 61 |
}} |
| 62 |
\if{html}{\out{<hr>}} |
| 63 |
\if{html}{\out{<a id="method-AppenderConsole-new"></a>}} |
| 64 |
\if{latex}{\out{\hypertarget{method-AppenderConsole-new}{}}} |
| 65 |
\subsection{Method \code{new()}}{ |
| 66 |
\subsection{Usage}{ |
| 67 |
\if{html}{\out{<div class="r">}}\preformatted{AppenderConsole$new( |
| 68 |
threshold = NA_integer_, |
| 69 |
layout = LayoutFormat$new(fmt = "\%L [\%t] \%m \%f", timestamp_fmt = "\%H:\%M:\%OS3", |
| 70 |
colors = getOption("lgr.colors", list())), |
| 71 |
filters = NULL, |
| 72 |
connection = NULL |
| 73 |
)}\if{html}{\out{</div>}} |
| 74 |
} |
| 75 |
|
| 76 |
\subsection{Arguments}{ |
| 77 |
\if{html}{\out{<div class="arguments">}} |
| 78 |
\describe{ |
| 79 |
\item{\code{connection}}{A connection or a \code{character} scalar. See the \code{file} |
| 80 |
argument of \code{\link[=cat]{cat()}} for more details. Defaults to \code{\link[=stdout]{stdout()}}, except |
| 81 |
inside \pkg{knitr} rendering processes where it defaults to \code{\link[=stderr]{stderr()}}.} |
| 82 |
} |
| 83 |
\if{html}{\out{</div>}} |
| 84 |
} |
| 85 |
} |
| 86 |
\if{html}{\out{<hr>}} |
| 87 |
\if{html}{\out{<a id="method-AppenderConsole-append"></a>}} |
| 88 |
\if{latex}{\out{\hypertarget{method-AppenderConsole-append}{}}} |
| 89 |
\subsection{Method \code{append()}}{ |
| 90 |
\subsection{Usage}{ |
| 91 |
\if{html}{\out{<div class="r">}}\preformatted{AppenderConsole$append(event)}\if{html}{\out{</div>}} |
| 92 |
} |
| 93 |
|
| 94 |
} |
| 95 |
\if{html}{\out{<hr>}} |
| 96 |
\if{html}{\out{<a id="method-AppenderConsole-set_connection"></a>}} |
| 97 |
\if{latex}{\out{\hypertarget{method-AppenderConsole-set_connection}{}}} |
| 98 |
\subsection{Method \code{set_connection()}}{ |
| 99 |
\subsection{Usage}{ |
| 100 |
\if{html}{\out{<div class="r">}}\preformatted{AppenderConsole$set_connection(connection)}\if{html}{\out{</div>}} |
| 101 |
} |
| 102 |
|
| 103 |
\subsection{Arguments}{ |
| 104 |
\if{html}{\out{<div class="arguments">}} |
| 105 |
\describe{ |
| 106 |
\item{\code{connection}}{A connection or a \code{character} scalar. See the \code{file} |
| 107 |
argument of \code{\link[=cat]{cat()}} for more details. Defaults to \code{\link[=stdout]{stdout()}}, except |
| 108 |
inside \pkg{knitr} rendering processes where it defaults to \code{\link[=stderr]{stderr()}}.} |
| 109 |
} |
| 110 |
\if{html}{\out{</div>}} |
| 111 |
} |
| 112 |
} |
| 113 |
} |