Closed marethyu closed 3 years ago
It prints to stderr, not stdout. As for disabling logging to stderr, you can do loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
@SpaceCheetah I tried that. This is my code
#include "loguru.hpp"
int main(int argc, char *argv[])
{
loguru::init(argc, argv);
loguru::add_file("everything.log", loguru::Append, loguru::Verbosity_MAX);
loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
LOG_F(INFO, "Doing some stuff...");
return 0;
}
It still prints to stderr. Even if I try to unset all of these variables
Verbosity g_stderr_verbosity = 0; // 0 (INFO) by default.
bool g_colorlogtostderr = true; // If you don't want color in your terminal.
unsigned g_flush_interval_ms = 0; // Unbuffered (0) by default.
bool g_preamble_header = true; // Prepend each log start by a descriptions line with all columns name?
bool g_preamble = true; // Prefix each log line with date, time etc?
// Turn off individual parts of the preamble
bool g_preamble_date = true; // The date field
bool g_preamble_time = true; // The time of the current day
bool g_preamble_uptime = true; // The time since init call
bool g_preamble_thread = true; // The logging thread
bool g_preamble_file = true; // The file from which the log originates from
bool g_preamble_verbose = true; // The verbosity field
bool g_preamble_pipe = true; // The pipe symbol right before the message
It still prints some stuff to stderr.
For me that exact script only prints the preamble, not "Doing some stuff". If you move the verbosity set before init, it doesn't print anything at all:
#include "loguru.hpp"
int main(int argc, char *argv[])
{
loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
loguru::init(argc, argv);
loguru::add_file("everything.log", loguru::Append, loguru::Verbosity_MAX);
LOG_F(INFO, "Doing some stuff...");
return 0;
}
For me that logs to everything.log but does nothing in console. Are you getting different behavior?
Oh, I get it now. It works now. Thanks @SpaceCheetah!
I prefer to have everything logged to a file while not printing anything to stdout. I tried different verbosity options and none of them prevents printing to stdout. Perhaps, this option doesn't exist?