Skip to content

return value? #26

@r2evans

Description

@r2evans

Have you considered invisibly returning the log message?

I find myself periodically doing something like:

if (x < badcondition) {
  logger::log_fatal("message of badness {x}")
  stop("message of badness ", x)
}

I can form the message once and use it in both logger::log_fatal and stop, but (1) I might like to take advantage of logger's formatting methodologies (e.g., glue or json); and (2) I think a more straight-forward approach is something like:

if (x < badcondition) {
  stop(logger::log_fatal("message of badness {x}"))
}

(This if course applies to other loggers, not just log_fatal.)

I'd think there are two good options for exactly what to return:

  • "message of badness 42", before some of the final formatting ... or
  • "[2019-07-12 17:04:42] FATAL message of badness 42", the literal full log entry

Thoughts?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions