Skip to content

Commit d526699

Browse files
committed
Core - Add Cef.GetMinLogLevel()
Gets the current log level
1 parent f76c6be commit d526699

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

CefSharp.Core.Runtime.RefAssembly/CefSharp.Core.Runtime.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public static void EnableWaitForBrowsersToClose() { }
8080
public static CefSharp.ICookieManager GetGlobalCookieManager(CefSharp.ICompletionCallback callback) { throw null; }
8181
public static CefSharp.IRequestContext GetGlobalRequestContext() { throw null; }
8282
public static string GetMimeType(string extension) { throw null; }
83+
public static int GetMinLogLevel() { throw null; }
8384
public static System.Threading.Tasks.Task<System.Collections.Generic.List<CefSharp.WebPluginInfo>> GetPlugins() { throw null; }
8485
public static bool Initialize(CefSharp.Core.CefSettingsBase cefSettings) { throw null; }
8586
public static bool Initialize(CefSharp.Core.CefSettingsBase cefSettings, bool performDependencyCheck) { throw null; }

CefSharp.Core.Runtime/Cef.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,11 @@ namespace CefSharp
752752
CefSetCrashKeyValue(StringUtils::ToNative(key), StringUtils::ToNative(value));
753753
}
754754

755+
static int GetMinLogLevel()
756+
{
757+
return cef_get_min_log_level();
758+
}
759+
755760
/// <summary>
756761
/// Register the Widevine CDM plugin.
757762
///

CefSharp.Core/Cef.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,56 @@ public static void SetCrashKeyValue(string c, string value)
525525
Core.Cef.SetCrashKeyValue(value, value);
526526
}
527527

528+
/// <summary>
529+
/// Gets the current log level.
530+
/// When <see cref="CefSettingsBase.LogSeverity"/> is set to <see cref="LogSeverity.Disable"/> then
531+
/// no messages will be written to the log file, but FATAL messages will still be output to stderr.
532+
/// When logging is disabled this method will return <see cref="LogSeverity.Fatal"/>.
533+
/// </summary>
534+
/// <returns>Current Log Level</returns>
535+
public static LogSeverity GetMinLogLevel()
536+
{
537+
var severity = Core.Cef.GetMinLogLevel();
538+
539+
//Manually convert the int into the enum
540+
//Values don't match (this is a difference in CEF/Chromium) implementation
541+
//we need to deal with it manually,
542+
//https://github.com/chromiumembedded/cef/blob/2a64387259cf14412e24c3267c8a1eb3b99a54e3/include/base/cef_logging.h#L186
543+
//const LogSeverity LOG_VERBOSE = -1;
544+
//const LogSeverity LOG_INFO = 0;
545+
//const LogSeverity LOG_WARNING = 1;
546+
//const LogSeverity LOG_ERROR = 2;
547+
//const LogSeverity LOG_FATAL = 3;
548+
549+
if (severity == -1)
550+
{
551+
return LogSeverity.Verbose;
552+
}
553+
554+
if (severity == 0)
555+
{
556+
return LogSeverity.Info;
557+
}
558+
559+
if (severity == 1)
560+
{
561+
return LogSeverity.Warning;
562+
}
563+
564+
if (severity == 2)
565+
{
566+
return LogSeverity.Error;
567+
}
568+
569+
if (severity == 3)
570+
{
571+
return LogSeverity.Fatal;
572+
}
573+
574+
//No matching type, return the integer value as enum
575+
return (LogSeverity)severity;
576+
}
577+
528578
/// <summary>
529579
/// Register the Widevine CDM plugin.
530580
///

0 commit comments

Comments
 (0)