printlog {luzlogr} | R Documentation |
Log a message
Description
Log a message
Usage
printlog(..., level = 0, ts = TRUE, cr = TRUE, flag = FALSE, flush = FALSE)
flaglog(...)
Arguments
... |
Expressions to be printed to the log |
level |
Priority level (numeric, optional) |
ts |
Print preceding timestamp? (logical, optional) |
cr |
Print trailing newline? (logical, optional) |
flag |
Flag this message (e.g. error or warning) (logical, optional) |
flush |
Immediately flush output to file (logical, optional) |
Details
Logs a message, which consists of zero or more printable objects. Simple objects (numeric and character) are printed together on a single line, whereas complex objects (data frames, etc) start on a new line by themselves.
If the current log was opened with sink
= TRUE,
messages are printed to the screen, otherwise not. Messages can be flagged;
flaglog
assumes
that the message is to be flagged, whereas printlog
does not.
Messages will only appear in the logfile if their level
exceeds
the log's loglevel
; this allows you to easily change the amount of
detail being logged.
Value
Invisible success (TRUE) or failure (FALSE).
Note
A message's preceding timestamp and following carriage return can be
suppressed using the ts
and cr
parameters.
See Also
Examples
logfile <- openlog("test.log")
printlog("message")
printlog(1, "plus", 1, "equals", 1 + 1)
closelog()
readLines(logfile)
file.remove(logfile)
logfile <- openlog("test", loglevel = 1)
printlog("This message will not appear", level = 0)
printlog("This message will appear", level = 1)
closelog()
readLines(logfile)
file.remove(logfile)