Last active
March 13, 2019 15:36
-
-
Save arnauldvm/90e88574070e254339271e50b5ef26b4 to your computer and use it in GitHub Desktop.
R logging framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(logging) | |
# LOG_LEVEL = "FINEST" | |
# LOG_LEVEL = "DEBUG" | |
LOG_LEVEL = "INFO" | |
# LOG_LEVEL = "ERROR" | |
logReset() | |
basicConfig(LOG_LEVEL) # bootstrapping the logging package | |
removeHandler("basic.stdout") | |
addHandler("mybasic.stdout", action=writeToConsole, level=LOG_LEVEL, | |
formatter=function(record) paste0(paste0(rep(" ", (50-record$level)/5), collapse=""), gsub("\\n", "\\\\n", record$msg)) ) | |
# Usage: | |
logfinest("x=%s", x) | |
logfiner(...) | |
logdebug(...) | |
loginfo(...) | |
logwarn(...) | |
logerror(...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment