Skip to content

Commit 4118097

Browse files
committed
pass layout fns without support for .timestamp
1 parent e56a916 commit 4118097

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

R/logger.R

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,26 @@ logger <- function(threshold, formatter, layout, appender) {
8181
)))
8282
}
8383

84-
res$record <- layout(
85-
level, res$message,
86-
namespace = namespace,
87-
.logcall = substitute(.logcall),
88-
.topcall = substitute(.topcall),
89-
.topenv = .topenv,
90-
.timestamp = .timestamp
91-
)
84+
## .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(
88+
level, res$message,
89+
namespace = namespace,
90+
.logcall = substitute(.logcall),
91+
.topcall = substitute(.topcall),
92+
.topenv = .topenv,
93+
.timestamp = .timestamp
94+
)
95+
}, error = function(e) {
96+
layout(
97+
level, res$message,
98+
namespace = namespace,
99+
.logcall = substitute(.logcall),
100+
.topcall = substitute(.topcall),
101+
.topenv = .topenv,
102+
)
103+
})
92104

93105
appender(res$record)
94106
invisible(res)

0 commit comments

Comments
 (0)