Skip to content

Commit 184c586

Browse files
committed
avoid wrapping layout call in tryCatch
1 parent 58735b3 commit 184c586

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

R/logger.R

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,24 @@ logger <- function(threshold, formatter, layout, appender) {
8282
}
8383

8484
## .timestamp arg was added in 0.4.1 and external layout fns might not support it yet
85-
## instead of checking formals of the layout fn, let's just try to call it not to delay OK fns
86-
res$record <- tryCatch({
87-
layout(
85+
if (".timestamp" %in% names(formals(layout))) {
86+
res$record <- layout(
8887
level, res$message,
8988
namespace = namespace,
9089
.logcall = substitute(.logcall),
9190
.topcall = substitute(.topcall),
9291
.topenv = .topenv,
9392
.timestamp = .timestamp
9493
)
95-
}, error = function(e) {
96-
layout(
94+
} else {
95+
res$record <- layout(
9796
level, res$message,
9897
namespace = namespace,
9998
.logcall = substitute(.logcall),
10099
.topcall = substitute(.topcall),
101100
.topenv = .topenv
102101
)
103-
})
102+
}
104103

105104
appender(res$record)
106105
invisible(res)

0 commit comments

Comments
 (0)