Suppress ERROR messages with log-severity=disable (issue #2581)
Also expose FATAL severity level.
This commit is contained in:
parent
f962b5863e
commit
995dd0ba19
|
@ -115,7 +115,13 @@ typedef enum {
|
|||
LOGSEVERITY_ERROR,
|
||||
|
||||
///
|
||||
// Completely disable logging.
|
||||
// FATAL logging.
|
||||
///
|
||||
LOGSEVERITY_FATAL,
|
||||
|
||||
///
|
||||
// Disable logging to file for all messages, and to stderr for messages with
|
||||
// severity less than FATAL.
|
||||
///
|
||||
LOGSEVERITY_DISABLE = 99
|
||||
} cef_log_severity_t;
|
||||
|
@ -290,9 +296,10 @@ typedef struct _cef_settings_t {
|
|||
|
||||
///
|
||||
// The log severity. Only messages of this severity level or higher will be
|
||||
// logged. Also configurable using the "log-severity" command-line switch with
|
||||
// a value of "verbose", "info", "warning", "error", "error-report" or
|
||||
// "disable".
|
||||
// logged. When set to DISABLE no messages will be written to the log file,
|
||||
// but FATAL messages will still be output to stderr. Also configurable using
|
||||
// the "log-severity" command-line switch with a value of "verbose", "info",
|
||||
// "warning", "error", "fatal" or "disable".
|
||||
///
|
||||
cef_log_severity_t log_severity;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ const char kLogSeverity_Verbose[] = "verbose";
|
|||
const char kLogSeverity_Info[] = "info";
|
||||
const char kLogSeverity_Warning[] = "warning";
|
||||
const char kLogSeverity_Error[] = "error";
|
||||
const char kLogSeverity_Fatal[] = "fatal";
|
||||
const char kLogSeverity_Disable[] = "disable";
|
||||
|
||||
// Path to resources directory.
|
||||
|
|
|
@ -17,6 +17,7 @@ extern const char kLogSeverity_Verbose[];
|
|||
extern const char kLogSeverity_Info[];
|
||||
extern const char kLogSeverity_Warning[];
|
||||
extern const char kLogSeverity_Error[];
|
||||
extern const char kLogSeverity_Fatal[];
|
||||
extern const char kLogSeverity_Disable[];
|
||||
extern const char kResourcesDirPath[];
|
||||
extern const char kLocalesDirPath[];
|
||||
|
|
|
@ -422,6 +422,9 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
|||
case LOGSEVERITY_ERROR:
|
||||
log_severity = switches::kLogSeverity_Error;
|
||||
break;
|
||||
case LOGSEVERITY_FATAL:
|
||||
log_severity = switches::kLogSeverity_Fatal;
|
||||
break;
|
||||
case LOGSEVERITY_DISABLE:
|
||||
log_severity = switches::kLogSeverity_Disable;
|
||||
break;
|
||||
|
@ -529,6 +532,9 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
|||
} else if (base::LowerCaseEqualsASCII(log_severity_str,
|
||||
switches::kLogSeverity_Error)) {
|
||||
log_severity = logging::LOG_ERROR;
|
||||
} else if (base::LowerCaseEqualsASCII(log_severity_str,
|
||||
switches::kLogSeverity_Fatal)) {
|
||||
log_severity = logging::LOG_FATAL;
|
||||
} else if (base::LowerCaseEqualsASCII(log_severity_str,
|
||||
switches::kLogSeverity_Disable)) {
|
||||
log_severity = LOGSEVERITY_DISABLE;
|
||||
|
@ -537,6 +543,10 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
|||
|
||||
if (log_severity == LOGSEVERITY_DISABLE) {
|
||||
log_settings.logging_dest = logging::LOG_NONE;
|
||||
// By default, ERROR and FATAL messages will always be output to stderr due
|
||||
// to the kAlwaysPrintErrorLevel value in base/logging.cc. We change the log
|
||||
// level here so that only FATAL messages are output.
|
||||
logging::SetMinLogLevel(logging::LOG_FATAL);
|
||||
} else {
|
||||
log_settings.logging_dest = logging::LOG_TO_ALL;
|
||||
logging::SetMinLogLevel(log_severity);
|
||||
|
|
Loading…
Reference in New Issue