Title: | muLogR |
---|---|
Description: | Logging and code structuring for R. Based on code from the RnBeads package. |
Authors: | Yassen Assenov [aut], Fabian Mueller [aut, cre] |
Maintainer: | Fabian Mueller <[email protected]> |
License: | GPL-3 |
Version: | 0.2 |
Built: | 2024-10-31 22:09:08 UTC |
Source: | https://github.com/demuellae/muLogR |
Gets the files currently used by the logger.
logger.getfiles()
logger.getfiles()
Vector storing the full names of the files that are being used by the logger. This vector contains NA
as an element if the logger is (also) using the console for its output. If the logger is not initialized, this function returns NULL
.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
logger.isinitialized
to check if logging is activated;
logger.start
for initializing a logger or starting a section
if (NA %in% logger.getfiles()) cat("Console logger is enabled\n")
if (NA %in% logger.getfiles()) cat("Console logger is enabled\n")
Checks if the logger is initialized.
logger.isinitialized()
logger.isinitialized()
TRUE
if the logger was initialized and is in use; FALSE
otherwise.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
logger.start
for initializing a logger or starting a section
if (!logger.isinitialized()) logger.start(fname = NA)
if (!logger.isinitialized()) logger.start(fname = NA)
Functions for logger management.
logger.start(txt = character(0), fname = NULL) logger.completed() logger.close()
logger.start(txt = character(0), fname = NULL) logger.completed() logger.close()
txt |
Description to add to the log file. The words |
fname |
Name of the log file and/or console. Note that at most one file name can be specified. The function
|
None (invisible NULL
).
logger.start
initializes the logger and/or starts a new section. logger.completed
completes the last
(innermost) open section in the log. logger.close
deinitializes the logger. Note that after reinitialization
or deinitialization, the information about the current output file, as well as any open sections, is deleted.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
logger.isinitialized
if (!logger.isinitialized()) logger.start(fname = NA) logger.start("Tests for Significance") logger.completed() logger.close()
if (!logger.isinitialized()) logger.start(fname = NA) logger.start("Tests for Significance") logger.completed() logger.close()
Appends a single-line status message to the log text file. The message is prepended by its type, which is one of
STATUS
, INFO
, WARNING
or ERROR
.
logger.status(txt) logger.info(txt) logger.warning(txt) logger.error(txt, terminate = FALSE)
logger.status(txt) logger.info(txt) logger.warning(txt) logger.error(txt, terminate = FALSE)
txt |
Text to add to the log file. This must be a |
terminate |
Flag indicating if the execution is to be terminated after this error message is added to the log. |
None (invisible NULL
).
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
logger.isinitialized
to check if logging is activated;
logger.start
for initializing a logger or starting a section
if (!logger.isinitialized()) logger.start(fname = NA) logger.status(c("Reached step", 2))
if (!logger.isinitialized()) logger.start(fname = NA) logger.status(c("Reached step", 2))
Validates the specified file or directory exists. Prints an error or a warning message to the log if it does not exist, it is not of the accepted type or is not accessible.
logger.validate.file(file, is.file = TRUE, terminate = TRUE)
logger.validate.file(file, is.file = TRUE, terminate = TRUE)
file |
Name of file or directory to validate. |
is.file |
Flag indicating if the given name must denote an existing file. If this is |
terminate |
Flag indicating if the execution is to be terminated in case the validation fails. This parameter
determines if an error message ( |
Whether the validation succeeded or not, invisibly. Note that when terminate
is TRUE
and the
validation fails, the R session is closed and thus no value is returned.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
if (!logger.isinitialized()) logger.start(fname = NA) # Validate the current working directory exists logger.validate.file(getwd(), FALSE)
if (!logger.isinitialized()) logger.start(fname = NA) # Validate the current working directory exists logger.validate.file(getwd(), FALSE)