1+ # Layout ------------------------------------------------------------------
2+
3+
14# ' Abstract Class for Layouts
25# '
36# ' [Appenders] pass [LogEvents][LogEvent] to a Layout which formats it for
@@ -331,14 +334,17 @@ LayoutJson <- R6::R6Class(
331334
332335 initialize = function (
333336 toJSON_args = list (auto_unbox = TRUE ),
334- timestamp_fmt = NULL
337+ timestamp_fmt = NULL ,
338+ excluded_properties = " rawMsg"
335339 ){
336340 self $ set_toJSON_args(toJSON_args )
337341 self $ set_timestamp_fmt(timestamp_fmt )
342+ self $ set_excluded_properties(excluded_properties )
338343 },
339344
340345 format_event = function (event ) {
341346 vals <- get(" values" , event )
347+ vals <- vals [! names(vals ) %in% self $ excluded_properties ]
342348 fmt <- get(" timestamp_fmt" , self )
343349
344350 if (! is.null(fmt )){
@@ -360,6 +366,9 @@ LayoutJson <- R6::R6Class(
360366 invisible (self )
361367 },
362368
369+
370+ # . . setters -------------------------------------------------------------
371+
363372 # ' @description Set a format that this Layout will apply to timestamps.
364373 # '
365374 # ' @param x
@@ -375,6 +384,14 @@ LayoutJson <- R6::R6Class(
375384 invisible (self )
376385 },
377386
387+ set_excluded_properties = function (x ){
388+ assert(is.null(x ) || is.character(x ))
389+ private $ .excluded_properties <- x
390+ invisible (self )
391+ },
392+
393+ # . . methods ----------------------------------------------------------------
394+
378395 toString = function () {
379396 fmt_class(class(self )[[1 ]])
380397 },
@@ -406,23 +423,40 @@ LayoutJson <- R6::R6Class(
406423
407424 ),
408425
426+
427+ # . . active fields ------------------------------------------------------
428+
409429 active = list (
410430 # ' @field toJSON_args a list of values passed on to [jsonlite::toJSON()]
411- toJSON_args = function () get(" .toJSON_args" , private ),
431+ toJSON_args = function () {
432+ get(" .toJSON_args" , private )
433+ },
412434
413435 # ' @field timestamp_fmt Used by `$format_event()` to format timestamps.
414- timestamp_fmt = function () get(" .timestamp_fmt" , private )
436+ timestamp_fmt = function () {
437+ get(" .timestamp_fmt" , private )
438+ },
439+
440+ # ' @field excluded_properties Used by `$format_event()` to exclude selected
441+ # ' properties before serialization
442+ excluded_properties = function () {
443+ get(" .excluded_properties" , private )
444+ }
415445 ),
416446
447+ # . . private --------------------------------------------------------------
417448 private = list (
418449 .toJSON_args = NULL ,
419- .timestamp_fmt = NULL
450+ .timestamp_fmt = NULL ,
451+ .excluded_properties = NULL
420452 )
421453)
422454
423455
424456
425457
458+ # utils -------------------------------------------------------------------
459+
426460fmt_timestamp = function (x , fmt ){
427461 if (is.character(fmt )){
428462 format(x , fmt )
0 commit comments