Class RealmLogger
A logger that logs messages originating from Realm. The default logger can be replaced by setting Default.
A few built-in implementations are provided by Console, Null, and Function(Action<string>),
but you can implement your own.
Namespace: Realms.Logging
Assembly: Realm.dll
Syntax
public abstract class RealmLogger
Constructors
| Edit this page View SourceRealmLogger()
Initializes a new instance of the RealmLogger class.
Declaration
protected RealmLogger()
Properties
| Edit this page View SourceConsole
Gets a RealmLogger.ConsoleLogger that outputs messages to the default console. For most project types, that will be using WriteLine() but certain platforms may use different implementations.
Declaration
public static RealmLogger Console { get; }
Property Value
Type | Description |
---|---|
RealmLogger | A RealmLogger instance that outputs to the platform's console. |
Default
Gets or sets a custom RealmLogger implementation that will be used by Realm whenever information must be logged.
Declaration
public static RealmLogger Default { get; set; }
Property Value
Type | Description |
---|---|
RealmLogger | The logger to be used for Realm-originating messages. |
LogLevel
Gets or sets the verbosity of log messages for all log categories via Realm.
Declaration
[Obsolete("Use GetLogLevel() and SetLogLevel().")]
public static LogLevel LogLevel { get; set; }
Property Value
Type | Description |
---|---|
LogLevel | The log level for Realm-originating messages. |
Null
Gets a RealmLogger.NullLogger that ignores all messages.
Declaration
public static RealmLogger Null { get; }
Property Value
Type | Description |
---|---|
RealmLogger | A RealmLogger that doesn't output any messages. |
Methods
| Edit this page View SourceFile(string, Encoding?)
Gets a RealmLogger.FileLogger that saves the log messages to a file.
Declaration
public static RealmLogger File(string filePath, Encoding? encoding = null)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | Path of the file to save messages to. The file is created if it does not already exists. |
Encoding | encoding | Character encoding to use. Defaults to UTF8 if not specified. |
Returns
Type | Description |
---|---|
RealmLogger | A RealmLogger instance that will save log messages to a file. |
Remarks
Please note that this logger is not optimized for performance, and could lead to overall sync performance slowdown with more verbose log levels.
Function(Action<LogLevel, LogCategory, string>)
Gets a RealmLogger.FunctionLogger that proxies Log calls to the supplied function.
Declaration
public static RealmLogger Function(Action<LogLevel, LogCategory, string> logFunction)
Parameters
Type | Name | Description |
---|---|---|
Action<LogLevel, LogCategory, string> | logFunction | Function to proxy log calls to. |
Returns
Type | Description |
---|---|
RealmLogger | A RealmLogger instance that will invoke |
Function(Action<LogLevel, string>)
Gets a RealmLogger.FunctionLogger that proxies Log calls to the supplied function.
Declaration
[Obsolete("Use Function(Action<LogLevel, LogCategory, string> logFunction).")]
public static RealmLogger Function(Action<LogLevel, string> logFunction)
Parameters
Type | Name | Description |
---|---|---|
Action<LogLevel, string> | logFunction | Function to proxy log calls to. |
Returns
Type | Description |
---|---|
RealmLogger | A RealmLogger instance that will invoke |
Function(Action<string>)
Gets a RealmLogger.FunctionLogger that proxies Log calls to the supplied function. The message will already be formatted with the default message formatting that includes a timestamp.
Declaration
public static RealmLogger Function(Action<string> logFunction)
Parameters
Type | Name | Description |
---|---|---|
Action<string> | logFunction | Function to proxy log calls to. |
Returns
Type | Description |
---|---|
RealmLogger | A RealmLogger instance that will invoke |
GetLogLevel(LogCategory?)
Gets the verbosity of log messages for the given category.
Declaration
public static LogLevel GetLogLevel(LogCategory? category = null)
Parameters
Type | Name | Description |
---|---|---|
LogCategory | category | The category to get the level for. Defaults to Realm if not specified. |
Returns
Type | Description |
---|---|
LogLevel | The log level used for the given category. |
Log(LogLevel, LogCategory, string)
Log a message at the supplied level and category.
Declaration
public void Log(LogLevel level, LogCategory category, string message)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level | The criticality level for the message. |
LogCategory | category | The category for the message. |
string | message | The message to log. |
Log(LogLevel, string)
Log a message at the supplied level and default category SDK.
Declaration
public void Log(LogLevel level, string message)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level | The criticality level for the message. |
string | message | The message to log. |
LogImpl(LogLevel, LogCategory, string)
The internal implementation being called from Log(LogLevel, LogCategory, string).
Declaration
protected abstract void LogImpl(LogLevel level, LogCategory category, string message)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level | The criticality level for the message. |
LogCategory | category | The category for the message. |
string | message | The message to log. |
SetLogLevel(LogLevel, LogCategory?)
Sets the verbosity of log messages for the given category.
Declaration
public static void SetLogLevel(LogLevel level, LogCategory? category = null)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | level | The log level to use for messages. |
LogCategory | category | The category to set the level for. Defaults to Realm if not specified. |