log_print {autometric} | R Documentation |
Print once to the log.
Description
Sample CPU load metrics and
print a single line to the log for each process in pids
.
Used for debugging and testing only. Not for users.
Usage
log_print(
path,
seconds = 1,
pids = c(local = Sys.getpid()),
error = getOption("autometric_error", TRUE)
)
Arguments
path |
Character string, path to a file to log resource usage.
On Windows, the path must point to a physical file on disk.
On Unix-like systems, Standard output is the most convenient option for high-performance computing scenarios where worker processes already write to log files. Such workers usually already redirect standard output to a physical file, as with a cluster like SLURM, or capture messages with Amazon CloudWatch. Normally, standard output and standard error are discouraged because
of how they interact with the R API and R console. However, the
exported user interface of |
seconds |
Positive number, number of seconds to sample CPU load metrics before printing to the log. This number should be at least 1, usually more. A low number of seconds could burden the operating system and generate large log files. |
pids |
Nonempty vector of non-negative integers
of process IDs to monitor. NOTE: On Mac OS, only the currently running
process can be monitored.
This is due to security restrictions around certain system calls, c.f.
https://os-tres.net/blog/2010/02/17/mac-os-x-and-task-for-pid-mach-call/. # nolint
If the |
error |
|
Value
NULL
(invisibly). Called for its side effects.
Examples
path = tempfile()
log_print(path = path)
log_read(path)
unlink(path)