Currently, para_client defines its para_log function via the
INIT_STDERR_LOGGING() macro which generates a log function that
writes to stderr. However, we will need to switch to a different,
curses-aware logging function when operating in interactive mode.
To support more than one log method the type of para_log is changed
from a function to a (public) pointer variable. This variable is
supposed to point to the log function currently in use so that the
application can simply set para_log differently in order to switch
between log functions.
The patch also changes the INIT_STDERR_LOGGING() macro to receive the
name of the log function to be defined and to let para_log point to
the newly defined function.
#include "signal.h"
#include "version.h"
#include "signal.h"
#include "version.h"
+__printf_2_3 void (*para_log)(int, const char*, ...) = daemon_log;
/** define the array of error lists needed by para_audiod */
INIT_AUDIOD_ERRLISTS;
/** define the array containing all supported audio formats */
/** define the array of error lists needed by para_audiod */
INIT_AUDIOD_ERRLISTS;
/** define the array containing all supported audio formats */
* \param ll The log level.
* \param fmt The format string describing the log message.
*/
* \param ll The log level.
* \param fmt The format string describing the log message.
*/
-__printf_2_3 void para_log(int ll, const char* fmt,...)
+__printf_2_3 void daemon_log(int ll, const char* fmt,...)
{
va_list argp;
FILE *fp;
{
va_list argp;
FILE *fp;
void daemon_set_loglevel(char *loglevel);
void daemon_set_default_log_colors(void);
void daemon_set_log_color_or_die(char const *arg);
void daemon_set_loglevel(char *loglevel);
void daemon_set_default_log_colors(void);
void daemon_set_log_color_or_die(char const *arg);
+__printf_2_3 void daemon_log(int ll, const char* fmt,...);
/** Daemon log configuration flags. */
enum daemon_flags {
/** Daemon log configuration flags. */
enum daemon_flags {
INIT_FADE_ERRLISTS;
static struct fade_args_info conf;
INIT_FADE_ERRLISTS;
static struct fade_args_info conf;
-__printf_2_3 void para_log(__a_unused int ll, const char *fmt, ...)
+__printf_2_3 void date_log(__a_unused int ll, const char *fmt, ...)
{
va_list argp;
time_t t1;
{
va_list argp;
time_t t1;
vprintf(fmt, argp);
va_end(argp);
}
vprintf(fmt, argp);
va_end(argp);
}
+__printf_2_3 void (*para_log)(int, const char*, ...) = date_log;
/*
* Open the mixer device.
/*
* Open the mixer device.
-__printf_2_3 void para_log(int ll, const char *fmt,...)
+__printf_2_3 void curses_log(int ll, const char *fmt,...)
rb_add_entry(color, msg);
wrefresh(bot.win);
}
rb_add_entry(color, msg);
wrefresh(bot.win);
}
+__printf_2_3 void (*para_log)(int, const char*, ...) = curses_log;
static void setup_signal_handling(void)
{
static void setup_signal_handling(void)
{
typeof(x) _x = (x); \
_x > 0? _x : -_x; })
typeof(x) _x = (x); \
_x > 0? _x : -_x; })
+
+extern __printf_2_3 void (*para_log)(int, const char*, ...);
/**
* Define a standard log function that always writes to stderr.
*
/**
* Define a standard log function that always writes to stderr.
*
+ * \param funcname The name of the function to be defined.
+ *
* \param loglevel_barrier If the loglevel of the current message
* is less than that, the message is going to be ignored.
*
*/
* \param loglevel_barrier If the loglevel of the current message
* is less than that, the message is going to be ignored.
*
*/
-#define INIT_STDERR_LOGGING(loglevel_barrier) \
- __printf_2_3 void para_log(int ll, const char* fmt,...) \
+#define DEFINE_STDERR_LOGGER(funcname, loglevel_barrier) \
+ __printf_2_3 void funcname(int ll, const char* fmt,...) \
{ \
va_list argp; \
if (ll < loglevel_barrier) \
{ \
va_list argp; \
if (ll < loglevel_barrier) \
vfprintf(stderr, fmt, argp); \
va_end(argp); \
}
vfprintf(stderr, fmt, argp); \
va_end(argp); \
}
+#define INIT_STDERR_LOGGING(loglevel_barrier) \
+ DEFINE_STDERR_LOGGER(stderr_log, loglevel_barrier); \
+ __printf_2_3 void (*para_log)(int, const char*, ...) = stderr_log;
/** Sent by para_client to initiate the authentication procedure. */
#define AUTH_REQUEST_MSG "auth rsa "
/** Sent by para_client to initiate the authentication procedure. */
#define AUTH_REQUEST_MSG "auth rsa "
int for_each_stat_item(char *item_buf, size_t num_bytes,
int (*item_handler)(int, char *));
int for_each_stat_item(char *item_buf, size_t num_bytes,
int (*item_handler)(int, char *));
-__printf_2_3 void para_log(int, const char*, ...);
-
/**
* Write a log message to a dynamically allocated string.
*
/**
* Write a log message to a dynamically allocated string.
*
#include "color.h"
#include "version.h"
#include "color.h"
#include "version.h"
+__printf_2_3 void (*para_log)(int, const char*, ...) = daemon_log;
+
/** Define the array of error lists needed by para_server. */
INIT_SERVER_ERRLISTS;
/** Define the array of error lists needed by para_server. */
INIT_SERVER_ERRLISTS;