Skip to content

Commit cadc0f5

Browse files
committed
treat rawMsg like all other properties
1 parent dcfcabd commit cadc0f5

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

R/LogEvent.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ LogEvent <- R6::R6Class(
5353
timestamp = Sys.time(),
5454
caller = NA,
5555
msg = NA,
56-
.rawMsg = msg,
56+
rawMsg = msg,
5757
...
5858
){
5959
assert(inherits(logger, "Logger"), "Logger must be a <Logger> object, not a ", class_fmt(logger))
@@ -65,7 +65,7 @@ LogEvent <- R6::R6Class(
6565
assign("timestamp", timestamp, self)
6666
assign("caller", caller, self)
6767
assign("msg", msg, self)
68-
assign(".rawMsg", .rawMsg, self)
68+
assign("rawMsg", rawMsg, self)
6969

7070
# custom values
7171
if (!missing(...)){
@@ -98,20 +98,20 @@ LogEvent <- R6::R6Class(
9898
#' event (equivalent to `get_logger(event$logger)`).
9999
.logger = NULL,
100100

101-
#' @field .rawMsg `character`. The raw log message without string
101+
#' @field rawMsg `character`. The raw log message without string
102102
#' interpolation.
103-
.rawMsg = NULL
103+
rawMsg = NULL
104104
),
105105

106106
active = list(
107107

108108
#' @field values `list`. All values stored in the `LogEvent`, including
109-
#' all *custom fields*, but not including `event$.logger` and `event$.rawMsg`.
109+
#' all *custom fields*, but not including `event$.logger`.
110110
values = function(){
111111
fixed_vals <- c("level", "timestamp", "logger", "caller", "msg")
112112
custom_vals <- setdiff(
113113
names(get(".__enclos_env__", self)[["self"]]),
114-
c(".__enclos_env__", "level_name", "initialize", "clone", "values", ".rawMsg",
114+
c(".__enclos_env__", "level_name", "initialize", "clone", "values", "rawMsg",
115115
".logger")
116116
)
117117
valnames <- union(fixed_vals, custom_vals) # to enforce order of fixed_vals

R/Logger.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Logger <- R6::R6Class(
235235
timestamp = timestamp,
236236
caller = caller,
237237
msg = msg,
238-
.rawMsg = rawMsg
238+
rawMsg = rawMsg
239239
)
240240
} else {
241241
dots <- list(...)
@@ -248,7 +248,7 @@ Logger <- R6::R6Class(
248248
timestamp = timestamp,
249249
caller = caller,
250250
msg = msg,
251-
.rawMsg = rawMsg
251+
rawMsg = rawMsg
252252
)
253253
} else {
254254
not_named <- vapply(names(dots), is_blank, TRUE, USE.NAMES = FALSE)
@@ -263,7 +263,7 @@ Logger <- R6::R6Class(
263263
timestamp = timestamp,
264264
caller = caller,
265265
msg = msg,
266-
.rawMsg = rawMsg
266+
rawMsg = rawMsg
267267
),
268268
dots[!not_named]
269269
)
@@ -941,7 +941,7 @@ LoggerGlue <- R6::R6Class(
941941
timestamp = timestamp,
942942
caller = caller,
943943
msg = msg,
944-
.rawMsg = rawMsg
944+
rawMsg = rawMsg
945945
),
946946
dots[custom_fields]
947947
)

tests/testthat/test_Logger.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ test_that("LoggerGlue$log - with 'msg' argument - throws a warning", {
487487
})
488488

489489

490-
test_that("Logger$log - with string interpolation - adds .rawMsg to event", {
490+
test_that("Logger$log - with string interpolation - adds rawMsg to event", {
491491
l <- get_logger("test")$set_propagate(FALSE)
492492

493493
on.exit({
@@ -497,11 +497,11 @@ test_that("Logger$log - with string interpolation - adds .rawMsg to event", {
497497
l$info("foo %s", "bar")
498498

499499
expect_identical(l$last_event$msg, "foo bar")
500-
expect_identical(l$last_event$.rawMsg, "foo %s")
500+
expect_identical(l$last_event$rawMsg, "foo %s")
501501
})
502502

503503

504-
test_that("LoggerGlue$log - with string interpolation - adds .rawMsg to event", {
504+
test_that("LoggerGlue$log - with string interpolation - adds rawMsg to event", {
505505
l <- get_logger_glue("testglue")$set_propagate(FALSE)
506506

507507
on.exit({
@@ -511,6 +511,6 @@ test_that("LoggerGlue$log - with string interpolation - adds .rawMsg to event",
511511
l$fatal("hash {x}", x = "baz")
512512

513513
expect_identical(as.character(l$last_event$msg), "hash baz")
514-
expect_identical(l$last_event$.rawMsg, "hash {x}")
514+
expect_identical(l$last_event$rawMsg, "hash {x}")
515515
})
516516

0 commit comments

Comments
 (0)