LIRC libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
lirc_log.c File Reference

(934bb04 2015-02-09 13:36:06 +0100)

Implements lirc_log.h. More...

#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <pwd.h>
#include <unistd.h>
#include <limits.h>
#include <ctype.h>
#include "lirc/lirc_log.h"

Go to the source code of this file.


#define HOSTNAME_LEN   128


int lirc_log_use_syslog (void)
void lirc_log_set_file (const char *s)
int lirc_log_open (const char *_progname, int _nodaemon, loglevel_t level)
int lirc_log_close (void)
int lirc_log_reopen (void)
int lirc_log_setlevel (loglevel_t level)
loglevel_t lirc_log_defaultlevel (void)
loglevel_t string2loglevel (const char *s)
void logprintf (loglevel_t prio, const char *format_str,...)
void logperror (loglevel_t prio, const char *fmt,...)
int lirc_log_get_clientlog (const char *basename, char *buffer, ssize_t size)
void hexdump (char *prefix, unsigned char *buf, int len)


char hostname [HOSTNAME_LEN+1]
FILE * lf = NULL
loglevel_t loglevel = LIRC_NOLOG
const char * syslogident = "lircd-" VERSION
const char * logfile = "syslog"
char progname [128] = { '?', '\0' }

Detailed Description

Implements lirc_log.h.

Ralph Metzler, Christoph Bartelmus

Definition in file lirc_log.c.

Function Documentation

void hexdump ( char *  prefix,
unsigned char *  buf,
int  len 

Print prefix + a hex dump of len bytes starting at *buf.

Definition at line 339 of file lirc_log.c.

int lirc_log_close ( void  )

Close the log previosly opened with lirc_log_open().

Definition at line 119 of file lirc_log.c.

loglevel_t lirc_log_defaultlevel ( void  )

Get the default level, from environment or hardcoded.

Definition at line 201 of file lirc_log.c.

int lirc_log_get_clientlog ( const char *  basename,
char *  buffer,
ssize_t  size 

Retrieve a client path for logging according to freedesktop specs.

basenameBasename for the logfile.
buffBuffer to store result in.
sizeSize of buffer
0 if OK, otherwise -1

Definition at line 310 of file lirc_log.c.

int lirc_log_open ( const char *  progname,
int  _nodaemon,
loglevel_t  level 

Open the log for upcoming logging

prognameName of application, made available in global progname
nodaemonIf true, program runs in foreground and logging is on also on stdout.
levelThe lowest level of messages to actually be logged.
0 if OK, else positive error code.

Definition at line 85 of file lirc_log.c.

void lirc_log_set_file ( const char *  s)

Set logfile. Either a regular path or the string 'syslog'; the latter does indeed use syslog(1) instead. Must be called before lirc_log_open().

Definition at line 74 of file lirc_log.c.

int lirc_log_setlevel ( loglevel_t  level)

Set the level. Returns 1 if ok, 0 on errors.

Definition at line 161 of file lirc_log.c.

int lirc_log_use_syslog ( void  )

Check if log is set up to use syslog or not.

Definition at line 68 of file lirc_log.c.

void logperror ( loglevel_t  prio,
const char *  fmt,

Prints a description of the last error to the log.

prioPriority of log request.
fmtprintf-style format string

Definition at line 288 of file lirc_log.c.

void logprintf ( loglevel_t  prio,
const char *  format_str,

Prints the log request to the log, if the priority fits.

prioPriority of log request
format_strFormat string in the usual C sense.
...Additional vararg parameters.

Definition at line 242 of file lirc_log.c.

loglevel_t string2loglevel ( const char *  level)

Convert a string, either a number or 'info', 'trace1', error etc. to a loglevel.

Definition at line 216 of file lirc_log.c.

Variable Documentation

loglevel_t loglevel = LIRC_NOLOG

The actual loglevel. Should not be changed directly by external code.

Definition at line 39 of file lirc_log.c.