Add the ability to specify log file location and severity level (issue #172).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@164 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2011-01-24 20:41:07 +00:00
parent 013c008775
commit 442cc1b89f
4 changed files with 50 additions and 7 deletions

View File

@ -1646,6 +1646,7 @@ public:
cef_string_clear(&locale);
if(extra_plugin_paths)
cef_string_list_free(extra_plugin_paths);
cef_string_clear(&log_file);
Init();
}
@ -1680,6 +1681,9 @@ public:
extra_plugin_paths = r.extra_plugin_paths ?
cef_string_list_copy(r.extra_plugin_paths) : NULL;
cef_string_copy(r.log_file.str, r.log_file.length, &log_file);
log_severity = r.log_severity;
return *this;
}

View File

@ -54,6 +54,18 @@ typedef long long int64;
extern "C" {
#endif
// Log severity levels.
enum cef_log_severity_t
{
LOGSEVERITY_VERBOSE = -1,
LOGSEVERITY_INFO,
LOGSEVERITY_WARNING,
LOGSEVERITY_ERROR,
LOGSEVERITY_ERROR_REPORT,
// Disables logging completely.
LOGSEVERITY_DISABLE = 99
};
// Initialization settings. Specify NULL or 0 to get the recommended default
// values.
typedef struct _cef_settings_t
@ -87,6 +99,15 @@ typedef struct _cef_settings_t
// List of file system paths that will be searched by the browser to locate
// plugins. This is in addition to the default search paths.
cef_string_list_t extra_plugin_paths;
// The directory and file name to use for the debug log. If empty, the
// default name of "debug.log" will be used and the file will be written
// to the application directory.
cef_string_t log_file;
// The log severity. Only messages of this severity level or higher will be
// logged.
cef_log_severity_t log_severity;
} cef_settings_t;
// Browser initialization settings. Specify NULL or 0 to get the recommended

View File

@ -66,14 +66,29 @@ CefProcessUIThread::~CefProcessUIThread() {
void CefProcessUIThread::Init() {
PlatformInit();
#ifndef _DEBUG
// Only log error messages and above in release build.
logging::SetMinLogLevel(logging::LOG_ERROR);
#endif
// Initialize the global CommandLine object.
CommandLine::Init(0, NULL);
const CefSettings& settings = _Context->settings();
// Initialize logging.
logging::LoggingDestination logging_dest;
if (settings.log_severity == LOGSEVERITY_DISABLE) {
logging_dest = logging::LOG_NONE;
} else {
#if defined(OS_WIN)
logging_dest = logging::LOG_ONLY_TO_FILE;
#else
logging_dest = logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG;
#endif
logging::SetMinLogLevel(settings.log_severity);
}
FilePath log_file = FilePath(CefString(&settings.log_file));
logging::InitLogging(log_file.value().c_str(), logging_dest,
logging::DONT_LOCK_LOG_FILE, logging::APPEND_TO_OLD_LOG_FILE,
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
// Initialize WebKit.
webkit_init_ = new BrowserWebKitInit();
@ -123,8 +138,6 @@ void CefProcessUIThread::Init() {
_Context->set_storage_context(new DOMStorageContext());
}
const CefSettings& settings = _Context->settings();
if (settings.user_agent.length > 0)
webkit_glue::SetUserAgent(CefString(&settings.user_agent));

View File

@ -69,6 +69,11 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
// Specify a cache path value.
//CefString(&settings.cache_path).FromASCII("c:\\temp\\cache");
#ifndef _DEBUG
// Only log error messages and higher in release build.
settings.log_severity = LOGSEVERITY_ERROR;
#endif
#ifdef TEST_SINGLE_THREADED_MESSAGE_LOOP
// Initialize the CEF with messages processed using the current application's
// message loop.