Debian Codegraph @

man/AppenderMemory.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/Appender.R
3 \name{AppenderMemory}
4 \alias{AppenderMemory}
5 \title{Abstract class for logging to memory buffers}
6 \description{
7 \strong{NOTE}: This is an \emph{abstract class}. Abstract classes cannot be instantiated
8 directly, but are exported for package developers that want to extend lgr -
9 for example by creating their own \link[=Appender]{Appenders} or \link[=Layout]{Layouts}.
10 Please refer to the \emph{see also} section for actual implementations of this
11 class.
12
13 AppenderMemory is extended by Appenders that retain an in-memory event
14 buffer, such as \link{AppenderBuffer} and \code{AppenderPushbullet} from the
15 \href{https://github.com/s-fleck/lgrExtra}{lgrExtra} package.
16 }
17 \seealso{
18 \link{LayoutFormat}
19
20 Other abstract classes:
21 \code{\link{Appender}},
22 \code{\link{AppenderTable}},
23 \code{\link{Filterable}}
24 }
25 \concept{abstract classes}
26 \section{Super classes}{
27 \code{\link[lgr:Filterable]{lgr::Filterable}} -> \code{\link[lgr:Appender]{lgr::Appender}} -> \code{AppenderMemory}
28 }
29 \section{Active bindings}{
30 \if{html}{\out{<div class="r6-active-bindings">}}
31 \describe{
32 \item{\code{flush_on_exit}}{A \code{logical} scalar. Should the buffer be flushed if
33 the Appender is destroyed (e.g. because the \R session is terminated)?}
34
35 \item{\code{flush_on_rotate}}{A \code{logical} scalar. Should the buffer be flushed when it is
36 rotated because \verb{$buffer_size} is exceeded?}
37
38 \item{\code{should_flush}}{A \code{function} with exactly one arguments: \code{event}.
39 \verb{$append()} calls this function internally on the current \link{LogEvent}
40 and flushes the buffer if it evaluates to \code{TRUE}.}
41
42 \item{\code{buffer_size}}{\code{integer} scalar \verb{>= 0}. Maximum number of \link{LogEvents}
43 to buffer.}
44
45 \item{\code{flush_threshold}}{A \code{numeric} or \code{character} threshold. \link{LogEvents}
46 with a \link{log_level} equal to or lower than this threshold trigger
47 flushing the buffer.}
48
49 \item{\code{buffer_events}}{A \code{list} of \link{LogEvents}. Contents of the buffer.}
50
51 \item{\code{buffer_events}}{A \code{data.frame}. Contents of the buffer converted
52 to a \code{data.frame}.}
53
54 \item{\code{buffer_events}}{A \code{data.frame}. Contents of the buffer converted
55 to a \code{data.table}.}
56 }
57 \if{html}{\out{</div>}}
58 }
59 \section{Methods}{
60 \subsection{Public methods}{
61 \itemize{
62 \item \href{#method-AppenderMemory-new}{\code{AppenderMemory$new()}}
63 \item \href{#method-AppenderMemory-append}{\code{AppenderMemory$append()}}
64 \item \href{#method-AppenderMemory-flush}{\code{AppenderMemory$flush()}}
65 \item \href{#method-AppenderMemory-clear}{\code{AppenderMemory$clear()}}
66 \item \href{#method-AppenderMemory-set_buffer_size}{\code{AppenderMemory$set_buffer_size()}}
67 \item \href{#method-AppenderMemory-set_should_flush}{\code{AppenderMemory$set_should_flush()}}
68 \item \href{#method-AppenderMemory-set_flush_on_exit}{\code{AppenderMemory$set_flush_on_exit()}}
69 \item \href{#method-AppenderMemory-set_flush_on_rotate}{\code{AppenderMemory$set_flush_on_rotate()}}
70 \item \href{#method-AppenderMemory-set_flush_threshold}{\code{AppenderMemory$set_flush_threshold()}}
71 \item \href{#method-AppenderMemory-show}{\code{AppenderMemory$show()}}
72 \item \href{#method-AppenderMemory-format}{\code{AppenderMemory$format()}}
73 }
74 }
75 \if{html}{\out{
76 <details><summary>Inherited methods</summary>
77 <ul>
78 <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>
79 <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>
80 <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>
81 <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>
82 <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>
83 <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>
84 </ul>
85 </details>
86 }}
87 \if{html}{\out{<hr>}}
88 \if{html}{\out{<a id="method-AppenderMemory-new"></a>}}
89 \if{latex}{\out{\hypertarget{method-AppenderMemory-new}{}}}
90 \subsection{Method \code{new()}}{
91 \subsection{Usage}{
92 \if{html}{\out{<div class="r">}}\preformatted{AppenderMemory$new(...)}\if{html}{\out{</div>}}
93 }
94
95 }
96 \if{html}{\out{<hr>}}
97 \if{html}{\out{<a id="method-AppenderMemory-append"></a>}}
98 \if{latex}{\out{\hypertarget{method-AppenderMemory-append}{}}}
99 \subsection{Method \code{append()}}{
100 \subsection{Usage}{
101 \if{html}{\out{<div class="r">}}\preformatted{AppenderMemory$append(event)}\if{html}{\out{</div>}}
102 }
103
104 }
105 \if{html}{\out{<hr>}}
106 \if{html}{\out{<a id="method-AppenderMemory-flush"></a>}}
107 \if{latex}{\out{\hypertarget{method-AppenderMemory-flush}{}}}
108 \subsection{Method \code{flush()}}{
109 Sends the buffer's contents to all attached Appenders and
110 then clears the Buffer
111 \subsection{Usage}{
112 \if{html}{\out{<div class="r">}}\preformatted{AppenderMemory$flush()}\if{html}{\out{</div>}}
113 }
114
115 }
116 \if{html}{\out{<hr>}}
117 \if{html}{\out{<a id="method-AppenderMemory-clear"></a>}}
118 \if{latex}{\out{\hypertarget{method-AppenderMemory-clear}{}}}
119 \subsection{Method \code{clear()}}{
120 Clears the buffer, discarding all buffered Events
121 \subsection{Usage}{
122 \if{html}{\out{<div class="r">}}\preformatted{AppenderMemory$clear()}\if{html}{\out{</div>}}
123 }
124
125 }
126 \if{html}{\out{<hr>}}
127 \if{html}{\out{<a id="method-AppenderMemory-set_buffer_size"></a>}}
128 \if{latex}{\out{\hypertarget{method-AppenderMemory-set_buffer_size}{}}}
129 \subsection{Method \code{set_buffer_size()}}{
130 Set the maximum size of the buffer
131 \subsection{Usage}{
132 \if{html}{\out{<div class="r">}}\preformatted{AppenderMemory$set_buffer_size(x)}\if{html}{\out{</div>}}
133 }
134
135 \subsection{Arguments}{
136 \if{html}{\out{<div class="arguments">}}
137 \describe{
138 \item{\code{x}}{an \code{integer} scalar \verb{>= 0}. Number of \link{LogEvents} to buffer.}
139 }
140 \if{html}{\out{</div>}}
141 }
142 }
143 \if{html}{\out{<hr>}}
144 \if{html}{\out{<a id="method-AppenderMemory-set_should_flush"></a>}}
145 \if{latex}{\out{\hypertarget{method-AppenderMemory-set_should_flush}{}}}
146 \subsection{Method \code{set_should_flush()}}{
147 Set function that can trigger flushing the buffer
148 \subsection{Usage}{
149 \if{html}{\out{<div class="r">}}\preformatted{AppenderMemory$set_should_flush(x)}\if{html}{\out{</div>}}
150 }
151
152 \subsection{Arguments}{
153 \if{html}{\out{<div class="arguments">}}
154 \describe{
155 \item{\code{x}}{A \code{function} with the single argument \code{event}. Setting \code{x} to
156 \code{NULL} is a shortcut for \code{function(event) FALSE}. See active bindings.}
157 }
158 \if{html}{\out{</div>}}
159 }
160 }
161 \if{html}{\out{<hr>}}
162 \if{html}{\out{<a id="method-AppenderMemory-set_flush_on_exit"></a>}}
163 \if{latex}{\out{\hypertarget{method-AppenderMemory-set_flush_on_exit}{}}}
164 \subsection{Method \code{set_flush_on_exit()}}{
165 Should the buffer be flushed when the Appender is destroyed?
166 \subsection{Usage}{
167 \if{html}{\out{<div class="r">}}\preformatted{AppenderMemory$set_flush_on_exit(x)}\if{html}{\out{</div>}}
168 }
169
170 \subsection{Arguments}{
171 \if{html}{\out{<div class="arguments">}}
172 \describe{
173 \item{\code{x}}{A \code{logical} scalar. See active bindings.}
174 }
175 \if{html}{\out{</div>}}
176 }
177 }
178 \if{html}{\out{<hr>}}
179 \if{html}{\out{<a id="method-AppenderMemory-set_flush_on_rotate"></a>}}
180 \if{latex}{\out{\hypertarget{method-AppenderMemory-set_flush_on_rotate}{}}}
181 \subsection{Method \code{set_flush_on_rotate()}}{
182 Should the buffer be flushed if \code{buffer_size} is exceeded?
183 \subsection{Usage}{
184 \if{html}{\out{<div class="r">}}\preformatted{AppenderMemory$set_flush_on_rotate(x)}\if{html}{\out{</div>}}
185 }
186
187 \subsection{Arguments}{
188 \if{html}{\out{<div class="arguments">}}
189 \describe{
190 \item{\code{x}}{A \code{logical} scalar. See active bindings.}
191 }
192 \if{html}{\out{</div>}}
193 }
194 }
195 \if{html}{\out{<hr>}}
196 \if{html}{\out{<a id="method-AppenderMemory-set_flush_threshold"></a>}}
197 \if{latex}{\out{\hypertarget{method-AppenderMemory-set_flush_threshold}{}}}
198 \subsection{Method \code{set_flush_threshold()}}{
199 Set threshold that triggers flushing
200 \subsection{Usage}{
201 \if{html}{\out{<div class="r">}}\preformatted{AppenderMemory$set_flush_threshold(level)}\if{html}{\out{</div>}}
202 }
203
204 \subsection{Arguments}{
205 \if{html}{\out{<div class="arguments">}}
206 \describe{
207 \item{\code{level}}{A \code{numeric} or \code{character} \link[=log_level]{threshold}. See
208 active bindings.}
209 }
210 \if{html}{\out{</div>}}
211 }
212 }
213 \if{html}{\out{<hr>}}
214 \if{html}{\out{<a id="method-AppenderMemory-show"></a>}}
215 \if{latex}{\out{\hypertarget{method-AppenderMemory-show}{}}}
216 \subsection{Method \code{show()}}{
217 Display the contents of the log table. Relies on the
218 \verb{$format_event} method of the \link{Layout} attached to this Appender.
219 \subsection{Usage}{
220 \if{html}{\out{<div class="r">}}\preformatted{AppenderMemory$show(threshold = NA_integer_, n = 20L)}\if{html}{\out{</div>}}
221 }
222
223 \subsection{Arguments}{
224 \if{html}{\out{<div class="arguments">}}
225 \describe{
226 \item{\code{threshold}}{\code{character} or \code{integer} scalar. The minimum log level
227 that should be displayed.}
228
229 \item{\code{n}}{\code{integer} scalar. Show only the last \code{n} log entries that match
230 \code{threshold}.}
231 }
232 \if{html}{\out{</div>}}
233 }
234 }
235 \if{html}{\out{<hr>}}
236 \if{html}{\out{<a id="method-AppenderMemory-format"></a>}}
237 \if{latex}{\out{\hypertarget{method-AppenderMemory-format}{}}}
238 \subsection{Method \code{format()}}{
239 \subsection{Usage}{
240 \if{html}{\out{<div class="r">}}\preformatted{AppenderMemory$format(color = FALSE, ...)}\if{html}{\out{</div>}}
241 }
242
243 }
244 }