KLone APIs | Modules | Data Structures | File List | Data Fields | Globals

klog.h File Reference

Go to the source code of this file.


Data Structures

struct  klog_args_s
struct  klog_mem_msg_s
struct  klog_mem_s
struct  klog_file_s
struct  klog_syslog_s
struct  klog_s

Defines

#define KLOG_FACILITY_UNKNOWN   -1
#define KLOG_LN_SZ   512 /* maximum log line size */
#define KLOG_ID_SZ   8 /* maximum log id size */
#define KLOG_MLIMIT_DFL   250 /* default number of log lines (mem) */
#define KLOG_FLIMIT_DFL   250 /* default number of log lines (file) */
#define KLOG_FSPLITS_DFL   4 /* default number of log files (file) */
#define KLOG_MEM_FULL(klm)   ((klm)->nmsgs >= (klm)->bound)
#define KLOG_PAGE_FULL(klf)   ((klf)->offset >= (klf)->nlines)
#define IS_KLOG_TYPE(t)   (t >= KLOG_TYPE_MEM && t <= KLOG_TYPE_SYSLOG)

Typedefs

typedef klog_args_s klog_args_t
typedef klog_mem_msg_s klog_mem_msg_t
typedef klog_mem_s klog_mem_t
typedef klog_file_s klog_file_t
typedef klog_syslog_s klog_syslog_t
typedef klog_s klog_t

Enumerations

enum  {
  KLOG_DEBUG, KLOG_INFO, KLOG_NOTICE, KLOG_WARNING,
  KLOG_ERR, KLOG_CRIT, KLOG_ALERT, KLOG_EMERG,
  KLOG_LEVEL_UNKNOWN
}

Functions

int klog_open (klog_args_t *ka, klog_t **pkl)
int klog (klog_t *kl, int level, const char *msg,...)
void klog_close (klog_t *kl)
int klog_flush (klog_t *kl)
int klog_getln (klog_t *kl, size_t nth, char ln[])
ssize_t klog_countln (klog_t *kl)
int klog_clear (klog_t *kl)
int klog_args (u_config_t *logsect, klog_args_t **pka)
void klog_args_free (klog_args_t *ka)
int klog_open_from_config (u_config_t *ls, klog_t **pkl)

Define Documentation

#define IS_KLOG_TYPE  )     (t >= KLOG_TYPE_MEM && t <= KLOG_TYPE_SYSLOG)
 

Definition at line 117 of file klog.h.

#define KLOG_FACILITY_UNKNOWN   -1
 

Definition at line 47 of file klog.h.

#define KLOG_FLIMIT_DFL   250 /* default number of log lines (file) */
 

Definition at line 58 of file klog.h.

#define KLOG_FSPLITS_DFL   4 /* default number of log files (file) */
 

Definition at line 60 of file klog.h.

#define KLOG_ID_SZ   8 /* maximum log id size */
 

Definition at line 54 of file klog.h.

#define KLOG_LN_SZ   512 /* maximum log line size */
 

Definition at line 52 of file klog.h.

#define KLOG_MEM_FULL klm   )     ((klm)->nmsgs >= (klm)->bound)
 

Definition at line 80 of file klog.h.

#define KLOG_MLIMIT_DFL   250 /* default number of log lines (mem) */
 

Definition at line 56 of file klog.h.

#define KLOG_PAGE_FULL klf   )     ((klf)->offset >= (klf)->nlines)
 

Definition at line 93 of file klog.h.


Typedef Documentation

typedef struct klog_args_s klog_args_t
 

Definition at line 50 of file klog.h.

typedef struct klog_file_s klog_file_t
 

Definition at line 97 of file klog.h.

typedef struct klog_mem_msg_s klog_mem_msg_t
 

Definition at line 73 of file klog.h.

typedef struct klog_mem_s klog_mem_t
 

Definition at line 84 of file klog.h.

typedef struct klog_syslog_s klog_syslog_t
 

Definition at line 106 of file klog.h.

typedef struct klog_s klog_t
 

Definition at line 139 of file klog.h.


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
KLOG_DEBUG 
KLOG_INFO 
KLOG_NOTICE 
KLOG_WARNING 
KLOG_ERR 
KLOG_CRIT 
KLOG_ALERT 
KLOG_EMERG 
KLOG_LEVEL_UNKNOWN 

Definition at line 23 of file klog.h.


Function Documentation

int klog klog_t kl,
int  level,
const char *  fmt,
... 
 

Log a KLOG message.

Parameters:
kl The klog context in use
level log severity, from KLOG_DEBUG to KLOG_EMERG
fmt log format string. Note that the conversion specification depends on the underying log type: KLOG_TYPE_MEM and KLOG_TYPE_FILE have printf(3)-like behaviour, while KLOG_TYPE_SYSLOG follows syslog(3) format rules.
... parameters to fmt
Returns:
  • 0 success
  • ~0 on failure

Definition at line 149 of file klog.c.

int klog_args u_config_t *  ls,
klog_args_t **  pka
 

create a klog_args_t object with configuration parameters read from a log subsection of a kloned configuration file

Parameters:
ls a log configuration record
pka the corresponding klog_args_t object as a value-result argument
Returns:
  • 0 success
  • ~0 on failure (pka MUST not be referenced)

Definition at line 37 of file klog.c.

void klog_args_free klog_args_t ka  ) 
 

Definition at line 339 of file klog.c.

int klog_clear klog_t kl  ) 
 

Remove all memory-log messages from the supplied klog_t context.

Parameters:
kl A KLOG_TYPE_MEM context
Returns:
  • 0 success
  • ~0 on failure

Definition at line 232 of file klog.c.

void klog_close klog_t kl  ) 
 

Destroy a klog_t object.

Parameters:
kl The klog_t object to be destroyed. When destroying a KLOG_TYPE_MEM object, all log messages are lost.
Returns:
nothing

Definition at line 184 of file klog.c.

ssize_t klog_countln klog_t kl  ) 
 

Count the number of lines in the supplied memory-log context kl.

Parameters:
kl A KLOG_TYPE_MEM context
Returns:
nothing

Definition at line 250 of file klog.c.

int klog_flush klog_t kl  ) 
 

flush all buffered data to the klog_t (file) device

Parameters:
kl a klog device
Returns:
  • 0 success
  • ~0 on failure

Definition at line 307 of file klog.c.

int klog_getln klog_t kl,
size_t  nth,
char  ln[]
 

Return the nth memory-log message.

Parameters:
kl A KLOG_TYPE_MEM context
nth a log message index: elements are retrieved in reverse order with respect to insertion
ln where the log string shall be stored: it must be a preallocated buffer, at least KLOG_MSG_SZ + 1 bytes long
Returns:
  • 0 success
  • ~0 on failure

Definition at line 212 of file klog.c.

int klog_open klog_args_t ka,
klog_t **  pkl
 

Create a new klog_t object from the corresponding klog_args_t.

Parameters:
ka an initialised klog_args_t object
pkl the newly created klog_t object as a value-result argument
Returns:
  • 0 success
  • ~0 on error (pkl MUST not be referenced)

Definition at line 96 of file klog.c.

int klog_open_from_config u_config_t *  ls,
klog_t **  pkl
 

create a klog_t object reading configuration parameters from a configuration "log" record

Parameters:
ls a log configuration record
pkl the corresponding klog_args_t object as a value-result argument
Returns:
  • 0 success
  • ~0 on failure (pka MUST not be referenced)

Definition at line 272 of file klog.c.