daroczig / logger

A lightweight, modern and flexible, log4j and futile.logger inspired logging utility for R
https://daroczig.github.io/logger
280 stars 41 forks source link

appender_tee() does not work? #62

Closed SulevR closed 3 years ago

SulevR commented 3 years ago

If I run

appender_tee(file.path(getwd(),'log.txt'))

R studio just prints out the structure:

function (lines) 
{
    appender_console(lines)
    appender_file(file)(lines)
}
<bytecode: 0x10c69fdc8>
<environment: 0x106ac7908>
attr(,"generator")
[1] "appender_tee(file = file.path(getwd(), \"log.txt\"))"

It seems that the function itself is not executed because if I now run

log_threshold(INFO) #define the level of output log information (DEBUG, INFO, WARN, ERROR)
log_formatter(formatter_glue)
log_layout(layout_glue_colors) #colorful log messages
appender_tee(file.path(getwd(),'log.txt')) #log both to console and to file
log_warn('I am a higher level log message that is very likely to be printed')

the WARN message is printed to the console but not to file (file was not created)

SulevR commented 3 years ago

Ah, got it: should use log_appender(appender_tee(file.path(getwd(),'log.txt')))