cryptsetup API
Public cryptsetup API
Macros | Functions
Cryptsetup logging

Macros

#define CRYPT_LOG_NORMAL   0
 
#define CRYPT_LOG_ERROR   1
 
#define CRYPT_LOG_VERBOSE   2
 
#define CRYPT_LOG_DEBUG   -1
 
#define CRYPT_LOG_DEBUG_JSON   -2
 

Functions

void crypt_set_log_callback (struct crypt_device *cd, void(*log)(int level, const char *msg, void *usrptr), void *usrptr)
 
void crypt_log (struct crypt_device *cd, int level, const char *msg)
 
void crypt_logf (struct crypt_device *cd, int level, const char *format,...)
 

Detailed Description

Set of functions and defines used in cryptsetup for logging purposes

Macro Definition Documentation

◆ CRYPT_LOG_DEBUG

#define CRYPT_LOG_DEBUG   -1

debug log level - always on stdout

Examples
crypt_log_usage.c.

◆ CRYPT_LOG_DEBUG_JSON

#define CRYPT_LOG_DEBUG_JSON   -2

debug log level - additional JSON output (for LUKS2)

◆ CRYPT_LOG_ERROR

#define CRYPT_LOG_ERROR   1

error log level

Examples
crypt_log_usage.c.

◆ CRYPT_LOG_NORMAL

#define CRYPT_LOG_NORMAL   0

normal log level

Examples
crypt_log_usage.c.

◆ CRYPT_LOG_VERBOSE

#define CRYPT_LOG_VERBOSE   2

verbose log level

Examples
crypt_log_usage.c.

Function Documentation

◆ crypt_log()

void crypt_log ( struct crypt_device *  cd,
int  level,
const char *  msg 
)

Defines log function or use the default one otherwise.

See also
crypt_set_log_callback
Parameters
cdcrypt device handle
levellog level
msglog message
Examples
crypt_log_usage.c.

◆ crypt_logf()

void crypt_logf ( struct crypt_device *  cd,
int  level,
const char *  format,
  ... 
)

Log function with variable arguments.

Parameters
cdcrypt device handle
levellog level
formatformatted log message

◆ crypt_set_log_callback()

void crypt_set_log_callback ( struct crypt_device *  cd,
void(*)(int level, const char *msg, void *usrptr)  log,
void *  usrptr 
)

Set log function.

Parameters
cdcrypt device handle (can be NULL to set default log function)
loguser defined log function reference
usrptrprovided identification in callback
levellog level below (debug messages can uses other levels)
msglog message
Examples
crypt_log_usage.c.