Couchbase Lite C
Couchbase Lite C API
Data Structures | Enumerations | Functions
Logging

Managing messages that Couchbase Lite logs at runtime. More...

Data Structures

struct  CBLLogFileConfiguration
 The properties for configuring logging to files. More...
 

Enumerations

enum  CBLLogDomain : uint8_t { kCBLLogDomainDatabase , kCBLLogDomainQuery , kCBLLogDomainReplicator , kCBLLogDomainNetwork }
 Subsystems that log information. More...
 
enum  CBLLogLevel : uint8_t {
  kCBLLogDebug , kCBLLogVerbose , kCBLLogInfo , kCBLLogWarning ,
  kCBLLogError , kCBLLogNone
}
 Levels of log messages. More...
 

Functions

void CBL_Log (CBLLogDomain domain, CBLLogLevel level, const char *format,...) __printflike(3
 Formats and writes a message to the log, in the given domain at the given level. More...
 
void void CBL_LogMessage (CBLLogDomain domain, CBLLogLevel level, FLSlice message)
 Writes a pre-formatted message to the log, exactly as given. More...
 

Console Logging and Custom Logging

typedef void(* CBLLogCallback) (CBLLogDomain domain, CBLLogLevel level, FLString message)
 A logging callback that the application can register. More...
 
CBLLogLevel CBLLog_ConsoleLevel (void)
 Gets the current log level for debug console logging. More...
 
void CBLLog_SetConsoleLevel (CBLLogLevel)
 Sets the detail level of logging. More...
 
CBLLogLevel CBLLog_CallbackLevel (void)
 Gets the current log level for debug console logging. More...
 
void CBLLog_SetCallbackLevel (CBLLogLevel)
 Sets the detail level of logging. More...
 
CBLLogCallback CBLLog_Callback (void)
 Gets the current log callback. More...
 
void CBLLog_SetCallback (CBLLogCallback _cbl_nullable callback)
 Sets the callback for receiving log messages. More...
 

Log File Configuration

const CBLLogFileConfiguration *_cbl_nullable CBLLog_FileConfig (void)
 Gets the current file logging configuration, or NULL if none is configured. More...
 
bool CBLLog_SetFileConfig (CBLLogFileConfiguration, CBLError *_cbl_nullable outError)
 Sets the file logging configuration, and begins logging to files. More...
 

Detailed Description

Managing messages that Couchbase Lite logs at runtime.

Typedef Documentation

◆ CBLLogCallback

typedef void(* CBLLogCallback) (CBLLogDomain domain, CBLLogLevel level, FLString message)

A logging callback that the application can register.

Parameters
domainThe domain of the message
levelThe severity level of the message.
messageThe actual formatted message.

Enumeration Type Documentation

◆ CBLLogDomain

enum CBLLogDomain : uint8_t

Subsystems that log information.

Enumerator
kCBLLogDomainDatabase 
kCBLLogDomainQuery 
kCBLLogDomainReplicator 
kCBLLogDomainNetwork 

◆ CBLLogLevel

enum CBLLogLevel : uint8_t

Levels of log messages.

Higher values are more important/severe. Each level includes the lower ones.

Enumerator
kCBLLogDebug 

Extremely detailed messages, only written by debug builds of CBL.

kCBLLogVerbose 

Detailed messages about normally-unimportant stuff.

kCBLLogInfo 

Messages about ordinary behavior.

kCBLLogWarning 

Messages warning about unlikely and possibly bad stuff.

kCBLLogError 

Messages about errors.

kCBLLogNone 

Disables logging entirely.

Function Documentation

◆ CBL_Log()

void CBL_Log ( CBLLogDomain  domain,
CBLLogLevel  level,
const char *  format,
  ... 
)

Formats and writes a message to the log, in the given domain at the given level.

Warning
This function takes a printf-style format string, with extra parameters to match the format placeholders, and has the same security vulnerabilities as other printf-style functions.

If you are logging a fixed string, call CBL_LogMessage instead, otherwise any % characters in the format string will be misinterpreted as placeholders and the dreaded Undefined Behavior will result, possibly including crashes or overwriting the stack.

Parameters
domainThe log domain to associate this message with.
levelThe severity of the message. If this is lower than the current minimum level for the domain (as set by CBLLog_SetConsoleLevel), nothing is logged.
formatA printf-style format string. % characters in this string introduce parameters, and corresponding arguments must follow.

◆ CBL_LogMessage()

void void CBL_LogMessage ( CBLLogDomain  domain,
CBLLogLevel  level,
FLSlice  message 
)

Writes a pre-formatted message to the log, exactly as given.

Parameters
domainThe log domain to associate this message with.
levelThe severity of the message. If this is lower than the current minimum level for the domain (as set by CBLLog_SetConsoleLevel), nothing is logged.
messageThe exact message to write to the log.

◆ CBLLog_Callback()

CBLLogCallback CBLLog_Callback ( void  )

Gets the current log callback.

◆ CBLLog_CallbackLevel()

CBLLogLevel CBLLog_CallbackLevel ( void  )

Gets the current log level for debug console logging.

Only messages at this level or higher will be logged to the callback.

◆ CBLLog_ConsoleLevel()

CBLLogLevel CBLLog_ConsoleLevel ( void  )

Gets the current log level for debug console logging.

Only messages at this level or higher will be logged to the console.

◆ CBLLog_FileConfig()

const CBLLogFileConfiguration *_cbl_nullable CBLLog_FileConfig ( void  )

Gets the current file logging configuration, or NULL if none is configured.

◆ CBLLog_SetCallback()

void CBLLog_SetCallback ( CBLLogCallback _cbl_nullable  callback)

Sets the callback for receiving log messages.

If set to NULL, no messages are logged to the console.

◆ CBLLog_SetCallbackLevel()

void CBLLog_SetCallbackLevel ( CBLLogLevel  )

Sets the detail level of logging.

Only messages whose level is ≥ the given level will be logged to the callback.

◆ CBLLog_SetConsoleLevel()

void CBLLog_SetConsoleLevel ( CBLLogLevel  )

Sets the detail level of logging.

Only messages whose level is ≥ the given level will be logged to the console.

◆ CBLLog_SetFileConfig()

bool CBLLog_SetFileConfig ( CBLLogFileConfiguration  ,
CBLError *_cbl_nullable  outError 
)

Sets the file logging configuration, and begins logging to files.