[Openais] [PATCH 7/9] logsys: port to new packed rec_ident version
Fabio M. Di Nitto
fdinitto at redhat.com
Wed Jun 17 22:33:07 PDT 2009
Committed revision 2250.
On Wed, 2009-06-17 at 12:53 +0200, Fabio M. Di Nitto wrote:
> Signed-off-by: Fabio M. Di Nitto <fdinitto at redhat.com>
> ---
> :100644 100644 4f97dfc... 77e8bd7... M exec/logsys.c
> :100644 100644 9901788... 3f4e425... M exec/main.c
> :100644 100644 b1f19c4... e7ead32... M exec/totemnet.c
> :100644 100644 7565805... 7d24ae1... M exec/totempg.c
> :100644 100644 e0d19ca... c0eb2e7... M exec/totemrrp.c
> :100644 100644 e14e377... 1907464... M exec/totemsrp.c
> :100644 100644 7a7d78b... 63eb519... M include/corosync/engine/logsys.h
> :100644 100644 5808d59... 6c113d1... M include/corosync/totem/totem.h
> :100644 100644 56457ba... 5d2163f... M test/logsysrec.c
> :100644 100644 e75d239... 4a2dc0f... M tools/corosync-fplay.c
> exec/logsys.c | 100 ++++++++++++++++++--------------------
> exec/main.c | 16 +++++--
> exec/totemnet.c | 15 +++--
> exec/totempg.c | 16 ++++--
> exec/totemrrp.c | 17 ++++--
> exec/totemsrp.c | 19 +++++---
> include/corosync/engine/logsys.h | 86 +++++++++++++++-----------------
> include/corosync/totem/totem.h | 16 +++---
> test/logsysrec.c | 8 ++-
> tools/corosync-fplay.c | 17 +++---
> 10 files changed, 164 insertions(+), 146 deletions(-)
>
> diff --git a/exec/logsys.c b/exec/logsys.c
> index 4f97dfc..77e8bd7 100644
> --- a/exec/logsys.c
> +++ b/exec/logsys.c
> @@ -414,12 +414,10 @@ static inline int strcpy_cutoff (char *dest, const char *src, size_t cutoff,
> * any number between % and character specify field length to pad or chop
> */
> static void log_printf_to_logs (
> - const char *subsys,
> + unsigned int rec_ident,
> const char *file_name,
> const char *function_name,
> int file_line,
> - unsigned int level,
> - unsigned int rec_ident,
> const char *buffer)
> {
> char normal_output_buffer[COMBINE_BUFFER_SIZE];
> @@ -433,16 +431,15 @@ static void log_printf_to_logs (
> size_t cutoff;
> unsigned int normal_len, syslog_len;
> int subsysid;
> + unsigned int level;
> int c;
>
> - if (rec_ident != LOGSYS_RECID_LOG) {
> + if (LOGSYS_DECODE_RECID(rec_ident) != LOGSYS_RECID_LOG) {
> return;
> }
>
> - subsysid = _logsys_config_subsys_get(subsys);
> - if (subsysid <= - 1) {
> - return;
> - }
> + subsysid = LOGSYS_DECODE_SUBSYSID(rec_ident);
> + level = LOGSYS_DECODE_LEVEL(rec_ident);
>
> while ((c = format_buffer[format_buffer_idx])) {
> cutoff = 0;
> @@ -463,8 +460,8 @@ static void log_printf_to_logs (
>
> switch (format_buffer[format_buffer_idx]) {
> case 's':
> - normal_p = subsys;
> - syslog_p = subsys;
> + normal_p = logsys_loggers[subsysid].subsys;
> + syslog_p = logsys_loggers[subsysid].subsys;
> break;
>
> case 'n':
> @@ -573,9 +570,13 @@ static void log_printf_to_logs (
> logsys_close_logfile(subsysid);
> logsys_loggers[subsysid].mode &= ~LOGSYS_MODE_OUTPUT_FILE;
> pthread_mutex_unlock (&logsys_config_mutex);
> - log_printf_to_logs(logsys_loggers[subsysid].subsys,
> + log_printf_to_logs(
> + LOGSYS_ENCODE_RECID(
> + LOGSYS_LEVEL_EMERG,
> + subsysid,
> + LOGSYS_RECID_LOG),
> __FILE__, __FUNCTION__, __LINE__,
> - LOGSYS_LEVEL_EMERG, 0, tmpbuffer);
> + tmpbuffer);
> }
> }
>
> @@ -598,9 +599,13 @@ static void log_printf_to_logs (
> snprintf(tmpbuffer, sizeof(tmpbuffer),
> "LOGSYS EMERGENCY: %s Unable to write to STDERR.",
> logsys_loggers[subsysid].subsys);
> - log_printf_to_logs(logsys_loggers[subsysid].subsys,
> - __FILE__, __FUNCTION__, __LINE__,
> - LOGSYS_LEVEL_EMERG, 0, tmpbuffer);
> + log_printf_to_logs(
> + LOGSYS_ENCODE_RECID(
> + LOGSYS_LEVEL_EMERG,
> + subsysid,
> + LOGSYS_RECID_LOG),
> + __FILE__, __FUNCTION__, __LINE__,
> + tmpbuffer);
> }
> }
> }
> @@ -609,17 +614,16 @@ static void record_print (const char *buf)
> {
> const int *buf_uint32t = (const int *)buf;
> unsigned int rec_size = buf_uint32t[0];
> - unsigned int level = buf_uint32t[1];
> - unsigned int rec_ident = buf_uint32t[2];
> - unsigned int file_line = buf_uint32t[3];
> + unsigned int rec_ident = buf_uint32t[1];
> + unsigned int file_line = buf_uint32t[2];
> unsigned int i;
> unsigned int words_processed;
> unsigned int arg_size_idx;
> const void *arguments[64];
> unsigned int arg_count;
>
> - arg_size_idx = 5;
> - words_processed = 5;
> + arg_size_idx = 4;
> + words_processed = 4;
> arg_count = 0;
>
> for (i = 0; words_processed < rec_size; i++) {
> @@ -636,29 +640,25 @@ static void record_print (const char *buf)
> */
>
> log_printf_to_logs (
> - (char *)arguments[0],
> + rec_ident,
> (char *)arguments[1],
> (char *)arguments[2],
> file_line,
> - level,
> - rec_ident,
> (char *)arguments[3]);
> }
>
> static int record_read (char *buf, int rec_idx, int *log_msg) {
> unsigned int rec_size;
> - unsigned int level;
> unsigned int rec_ident;
> int firstcopy, secondcopy;
>
> rec_size = flt_data[rec_idx];
> - level = flt_data[(rec_idx + 1) % flt_data_size];
> - rec_ident = flt_data[(rec_idx + 2) % flt_data_size];
> + rec_ident = flt_data[(rec_idx + 1) % flt_data_size];
>
> /*
> * Not a log record
> */
> - if (rec_ident != LOGSYS_RECID_LOG) {
> + if (LOGSYS_DECODE_RECID(rec_ident) != LOGSYS_RECID_LOG) {
> *log_msg = 0;
> return ((rec_idx + rec_size) % flt_data_size);
> }
> @@ -1081,12 +1081,10 @@ int _logsys_rec_init (unsigned int size)
> */
>
> void _logsys_log_rec (
> - int subsysid,
> + unsigned int rec_ident,
> const char *function_name,
> const char *file_name,
> int file_line,
> - unsigned int level,
> - unsigned int rec_ident,
> ...)
> {
> va_list ap;
> @@ -1098,13 +1096,16 @@ void _logsys_log_rec (
> unsigned int record_reclaim_size;
> unsigned int index_start;
> int words_written;
> + int subsysid;
>
> record_reclaim_size = 0;
>
> + subsysid = LOGSYS_DECODE_SUBSYSID(rec_ident);
> +
> /*
> * Decode VA Args
> */
> - va_start (ap, rec_ident);
> + va_start (ap, file_line);
> arguments = 3;
> for (;;) {
> buf_args[arguments] = va_arg (ap, void *);
> @@ -1139,7 +1140,7 @@ void _logsys_log_rec (
> /*
> * Reclaim data needed for record including 4 words for the header
> */
> - records_reclaim (idx, record_reclaim_size + 5);
> + records_reclaim (idx, record_reclaim_size + 4);
>
> /*
> * Write record size of zero and rest of header information
> @@ -1147,9 +1148,6 @@ void _logsys_log_rec (
> flt_data[idx++] = 0;
> idx_word_step(idx);
>
> - flt_data[idx++] = level;
> - idx_word_step(idx);
> -
> flt_data[idx++] = rec_ident;
> idx_word_step(idx);
>
> @@ -1227,7 +1225,7 @@ void _logsys_log_rec (
> * the new head position and commit the new head.
> */
> logsys_lock();
> - if (rec_ident == LOGSYS_RECID_LOG) {
> + if (LOGSYS_DECODE_RECID(rec_ident) == LOGSYS_RECID_LOG) {
> log_requests_pending += 1;
> }
> if (log_requests_pending == 0) {
> @@ -1239,21 +1237,20 @@ void _logsys_log_rec (
> }
>
> void _logsys_log_vprintf (
> - int subsysid,
> + unsigned int rec_ident,
> const char *function_name,
> const char *file_name,
> int file_line,
> - unsigned int level,
> - unsigned int rec_ident,
> const char *format,
> va_list ap)
> {
> char logsys_print_buffer[COMBINE_BUFFER_SIZE];
> unsigned int len;
> + unsigned int level;
> + int subsysid;
>
> - if (subsysid <= -1) {
> - subsysid = LOGSYS_MAX_SUBSYS_COUNT;
> - }
> + subsysid = LOGSYS_DECODE_SUBSYSID(rec_ident);
> + level = LOGSYS_DECODE_LEVEL(rec_ident);
>
> if ((level > logsys_loggers[subsysid].syslog_priority) &&
> (level > logsys_loggers[subsysid].logfile_priority) &&
> @@ -1270,12 +1267,11 @@ void _logsys_log_vprintf (
> /*
> * Create a log record
> */
> - _logsys_log_rec (subsysid,
> + _logsys_log_rec (
> + rec_ident,
> function_name,
> file_name,
> file_line,
> - level,
> - rec_ident,
> logsys_print_buffer, len + 1,
> LOGSYS_REC_END);
>
> @@ -1284,9 +1280,9 @@ void _logsys_log_vprintf (
> * Output (and block) if the log mode is not threaded otherwise
> * expect the worker thread to output the log data once signaled
> */
> - log_printf_to_logs (logsys_loggers[subsysid].subsys,
> - file_name, function_name, file_line, level, rec_ident,
> - logsys_print_buffer);
> + log_printf_to_logs (rec_ident,
> + file_name, function_name, file_line,
> + logsys_print_buffer);
> } else {
> /*
> * Signal worker thread to display logging output
> @@ -1296,20 +1292,18 @@ void _logsys_log_vprintf (
> }
>
> void _logsys_log_printf (
> - int subsysid,
> + unsigned int rec_ident,
> const char *function_name,
> const char *file_name,
> int file_line,
> - unsigned int level,
> - unsigned int rec_ident,
> const char *format,
> ...)
> {
> va_list ap;
>
> va_start (ap, format);
> - _logsys_log_vprintf (subsysid, function_name, file_name, file_line,
> - level, rec_ident, format, ap);
> + _logsys_log_vprintf (rec_ident, function_name, file_name, file_line,
> + format, ap);
> va_end (ap);
> }
>
> diff --git a/exec/main.c b/exec/main.c
> index 9901788..3f4e425 100644
> --- a/exec/main.c
> +++ b/exec/main.c
> @@ -551,15 +551,23 @@ static void ipc_log_printf (const char *format, ...) {
>
> va_start (ap, format);
>
> - _logsys_log_vprintf (ipc_subsys_id, __FUNCTION__,
> - __FILE__, __LINE__, LOGSYS_LEVEL_ERROR, LOGSYS_RECID_LOG, format, ap);
> + _logsys_log_vprintf (
> + LOGSYS_ENCODE_RECID(ipc_subsys_id,
> + LOGSYS_LEVEL_ERROR,
> + LOGSYS_RECID_LOG),
> + __FUNCTION__, __FILE__, __LINE__,
> + format, ap);
>
> va_end (ap);
> }
>
> static void ipc_fatal_error(const char *error_msg) {
> - _logsys_log_printf (ipc_subsys_id, __FUNCTION__,
> - __FILE__, __LINE__, LOGSYS_LEVEL_ERROR, LOGSYS_RECID_LOG, "%s", error_msg);
> + _logsys_log_printf (
> + LOGSYS_ENCODE_RECID(ipc_subsys_id,
> + LOGSYS_LEVEL_ERROR,
> + LOGSYS_RECID_LOG),
> + __FUNCTION__, __FILE__, __LINE__,
> + "%s", error_msg);
> exit(EXIT_FAILURE);
> }
>
> diff --git a/exec/totemnet.c b/exec/totemnet.c
> index b1f19c4..e7ead32 100644
> --- a/exec/totemnet.c
> +++ b/exec/totemnet.c
> @@ -157,13 +157,13 @@ struct totemnet_instance {
>
> int totemnet_subsys_id;
>
> - void (*totemnet_log_printf) (int subsys,
> + void (*totemnet_log_printf) (
> + unsigned int rec_ident,
> const char *function,
> const char *file,
> - int line, unsigned int level,
> - unsigned int rec_ident,
> + int line,
> const char *format,
> - ...)__attribute__((format(printf, 7, 8)));
> + ...)__attribute__((format(printf, 5, 6)));
>
> hdb_handle_t handle;
>
> @@ -246,9 +246,12 @@ static void totemnet_instance_initialize (struct totemnet_instance *instance)
>
> #define log_printf(level, format, args...) \
> do { \
> - instance->totemnet_log_printf (instance->totemnet_subsys_id, \
> + instance->totemnet_log_printf ( \
> + LOGSYS_ENCODE_RECID(level, \
> + instance->totemnet_subsys_id, \
> + LOGSYS_RECID_LOG), \
> __FUNCTION__, __FILE__, __LINE__, \
> - level, LOGSYS_RECID_LOG, (const char *)format, ##args); \
> + (const char *)format, ##args); \
> } while (0);
>
>
> diff --git a/exec/totempg.c b/exec/totempg.c
> index 7565805..7d24ae1 100644
> --- a/exec/totempg.c
> +++ b/exec/totempg.c
> @@ -161,9 +161,12 @@ static int totempg_log_level_warning;
> static int totempg_log_level_notice;
> static int totempg_log_level_debug;
> static int totempg_subsys_id;
> -static void (*totempg_log_printf) (int subsys_id, const char *function,
> - const char *file, int line, unsigned int level, unsigned int rec_ident,
> - const char *format, ...) __attribute__((format(printf, 7, 8)));
> +static void (*totempg_log_printf) (
> + unsigned int rec_ident,
> + const char *function,
> + const char *file,
> + int line,
> + const char *format, ...) __attribute__((format(printf, 5, 6)));
>
> struct totem_config *totempg_totem_config;
>
> @@ -241,8 +244,11 @@ static pthread_mutex_t mcast_msg_mutex = PTHREAD_MUTEX_INITIALIZER;
>
> #define log_printf(level, format, args...) \
> do { \
> - totempg_log_printf (totempg_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, level, LOGSYS_RECID_LOG, \
> + totempg_log_printf ( \
> + LOGSYS_ENCODE_RECID(level, \
> + totempg_subsys_id, \
> + LOGSYS_RECID_LOG), \
> + __FUNCTION__, __FILE__, __LINE__, \
> format, ##args); \
> } while (0);
>
> diff --git a/exec/totemrrp.c b/exec/totemrrp.c
> index e0d19ca..c0eb2e7 100644
> --- a/exec/totemrrp.c
> +++ b/exec/totemrrp.c
> @@ -208,9 +208,12 @@ struct totemrrp_instance {
>
> int totemrrp_subsys_id;
>
> - void (*totemrrp_log_printf) (int subsys, const char *function,
> - const char *file, int line, unsigned int level, unsigned int rec_ident,
> - const char *format, ...)__attribute__((format(printf, 7, 8)));
> + void (*totemrrp_log_printf) (
> + unsigned int rec_ident,
> + const char *function,
> + const char *file,
> + int line,
> + const char *format, ...)__attribute__((format(printf, 5, 6)));
>
> hdb_handle_t handle;
>
> @@ -473,9 +476,11 @@ DECLARE_HDB_DATABASE (totemrrp_instance_database,NULL);
> #define log_printf(level, format, args...) \
> do { \
> rrp_instance->totemrrp_log_printf ( \
> - rrp_instance->totemrrp_subsys_id, \
> - __FUNCTION__, __FILE__, __LINE__, level, \
> - LOGSYS_RECID_LOG, format, ##args); \
> + LOGSYS_ENCODE_RECID(level, \
> + rrp_instance->totemrrp_subsys_id, \
> + LOGSYS_RECID_LOG), \
> + __FUNCTION__, __FILE__, __LINE__, \
> + format, ##args); \
> } while (0);
>
> /*
> diff --git a/exec/totemsrp.c b/exec/totemsrp.c
> index e14e377..1907464 100644
> --- a/exec/totemsrp.c
> +++ b/exec/totemsrp.c
> @@ -437,10 +437,12 @@ struct totemsrp_instance {
>
> int totemsrp_subsys_id;
>
> - void (*totemsrp_log_printf) (int subsys,
> - const char *function, const char *file,
> - int line, unsigned int level, unsigned int rec_ident,
> - const char *format, ...)__attribute__((format(printf, 7, 8)));;
> + void (*totemsrp_log_printf) (
> + unsigned int rec_ident,
> + const char *function,
> + const char *file,
> + int line,
> + const char *format, ...)__attribute__((format(printf, 5, 6)));;
>
> enum memb_state memb_state;
>
> @@ -627,9 +629,12 @@ static const char *rundir = NULL;
>
> #define log_printf(level, format, args...) \
> do { \
> - instance->totemsrp_log_printf (instance->totemsrp_subsys_id, \
> - __FUNCTION__, __FILE__, __LINE__, level, \
> - LOGSYS_RECID_LOG, format, ##args); \
> + instance->totemsrp_log_printf ( \
> + LOGSYS_ENCODE_RECID(level, \
> + instance->totemsrp_subsys_id, \
> + LOGSYS_RECID_LOG), \
> + __FUNCTION__, __FILE__, __LINE__, \
> + format, ##args); \
> } while (0);
>
> static void totemsrp_instance_initialize (struct totemsrp_instance *instance)
> diff --git a/include/corosync/engine/logsys.h b/include/corosync/engine/logsys.h
> index 7a7d78b..63eb519 100644
> --- a/include/corosync/engine/logsys.h
> +++ b/include/corosync/engine/logsys.h
> @@ -172,37 +172,31 @@ extern unsigned int _logsys_subsys_create (const char *subsys);
> extern int _logsys_rec_init (unsigned int size);
>
> extern void _logsys_log_vprintf (
> - int subsysid,
> + unsigned int rec_ident,
> const char *function_name,
> const char *file_name,
> int file_line,
> - unsigned int level,
> - unsigned int rec_ident,
> const char *format,
> - va_list ap) __attribute__((format(printf, 7, 0)));
> + va_list ap) __attribute__((format(printf, 5, 0)));
>
> extern void _logsys_log_printf (
> - int subsysid,
> + unsigned int rec_ident,
> const char *function_name,
> const char *file_name,
> int file_line,
> - unsigned int level,
> - unsigned int rec_ident,
> const char *format,
> - ...) __attribute__((format(printf, 7, 8)));
> + ...) __attribute__((format(printf, 5, 6)));
>
> extern void _logsys_log_rec (
> - int subsysid,
> + unsigned int rec_ident,
> const char *function_name,
> const char *file_name,
> int file_line,
> - unsigned int level,
> - unsigned int rec_ident,
> ...);
>
> extern int _logsys_wthread_create (void);
>
> -static unsigned int logsys_subsys_id __attribute__((unused)) = -1;
> +static int logsys_subsys_id __attribute__((unused)) = LOGSYS_MAX_SUBSYS_COUNT;
>
> /*
> * External API - init
> @@ -356,76 +350,76 @@ static void logsys_subsys_init (void) \
>
> #define log_rec(rec_ident, args...) \
> do { \
> - _logsys_log_rec (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, rec_ident, 0, ##args, \
> + _logsys_log_rec (rec_ident, __FUNCTION__, \
> + __FILE__, __LINE__, ##args, \
> LOGSYS_REC_END); \
> } while(0)
>
> #define log_printf(level, format, args...) \
> do { \
> - _logsys_log_printf (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, level, LOGSYS_RECID_LOG, \
> + _logsys_log_printf ( \
> + LOGSYS_ENCODE_RECID(level, \
> + logsys_subsys_id, \
> + LOGSYS_RECID_LOG), \
> + __FUNCTION__, __FILE__, __LINE__, \
> format, ##args); \
> } while(0)
>
> #define ENTER() do { \
> - _logsys_log_rec (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, LOGSYS_LEVEL_DEBUG, \
> - LOGSYS_RECID_ENTER, LOGSYS_REC_END); \
> + _logsys_log_rec ( \
> + LOGSYS_ENCODE_RECID(LOGSYS_LEVEL_DEBUG, \
> + logsys_subsys_id, \
> + LOGSYS_RECID_ENTER), \
> + __FUNCTION__, __FILE__, __LINE__, LOGSYS_REC_END); \
> } while(0)
>
> #define LEAVE() do { \
> - _logsys_log_rec (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, LOGSYS_LEVEL_DEBUG, \
> - LOGSYS_RECID_LEAVE, LOGSYS_REC_END); \
> + _logsys_log_rec ( \
> + LOGSYS_ENCODE_RECID(LOGSYS_LEVEL_DEBUG, \
> + logsys_subsys_id, \
> + LOGSYS_RECID_LEAVE), \
> + __FUNCTION__, __FILE__, __LINE__, LOGSYS_REC_END); \
> +} while(0)
> +
> +#define TRACE(recid, format, args...) do { \
> + _logsys_log_printf ( \
> + LOGSYS_ENCODE_RECID(LOGSYS_LEVEL_DEBUG, \
> + logsys_subsys_id, \
> + recid), \
> + __FUNCTION__, __FILE__, __LINE__, \
> + format, ##args); \
> } while(0)
>
> #define TRACE1(format, args...) do { \
> - _logsys_log_printf (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, LOGSYS_LEVEL_DEBUG, \
> - LOGSYS_RECID_TRACE1, format, ##args); \
> + TRACE(LOGSYS_RECID_TRACE1, format, ##args); \
> } while(0)
>
> #define TRACE2(format, args...) do { \
> - _logsys_log_printf (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, LOGSYS_LEVEL_DEBUG, \
> - LOGSYS_RECID_TRACE2, format, ##args); \
> + TRACE(LOGSYS_RECID_TRACE2, format, ##args); \
> } while(0)
>
> #define TRACE3(format, args...) do { \
> - _logsys_log_printf (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, LOGSYS_LEVEL_DEBUG, \
> - LOGSYS_RECID_TRACE3, format, ##args); \
> + TRACE(LOGSYS_RECID_TRACE3, format, ##args); \
> } while(0)
>
> #define TRACE4(format, args...) do { \
> - _logsys_log_printf (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, LOGSYS_LEVEL_DEBUG, \
> - LOGSYS_RECID_TRACE4, format, ##args); \
> + TRACE(LOGSYS_RECID_TRACE4, format, ##args); \
> } while(0)
>
> #define TRACE5(format, args...) do { \
> - _logsys_log_printf (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, LOGSYS_LEVEL_DEBUG, \
> - LOGSYS_RECID_TRACE5, format, ##args); \
> + TRACE(LOGSYS_RECID_TRACE5, format, ##args); \
> } while(0)
>
> #define TRACE6(format, args...) do { \
> - _logsys_log_printf (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, LOGSYS_LEVEL_DEBUG, \
> - LOGSYS_RECID_TRACE6, format, ##args); \
> + TRACE(LOGSYS_RECID_TRACE6, format, ##args); \
> } while(0)
>
> #define TRACE7(format, args...) do { \
> - _logsys_log_printf (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, LOGSYS_LEVEL_DEBUG, \
> - LOGSYS_RECID_TRACE7, format, ##args); \
> + TRACE(LOGSYS_RECID_TRACE7, format, ##args); \
> } while(0)
>
> #define TRACE8(format, args...) do { \
> - _logsys_log_printf (logsys_subsys_id, __FUNCTION__, \
> - __FILE__, __LINE__, LOGSYS_LEVEL_DEBUG, \
> - LOGSYS_RECID_TRACE8, format, ##args); \
> + TRACE(LOGSYS_RECID_TRACE8, format, ##args); \
> } while(0)
>
> #endif /* LOGSYS_UTILS_ONLY */
> diff --git a/include/corosync/totem/totem.h b/include/corosync/totem/totem.h
> index 5808d59..6c113d1 100644
> --- a/include/corosync/totem/totem.h
> +++ b/include/corosync/totem/totem.h
> @@ -58,15 +58,13 @@ struct totem_interface {
> };
>
> struct totem_logging_configuration {
> - void (*log_printf) (
> - int subsys,
> - const char *function_name,
> - const char *file_name,
> - int file_line,
> - unsigned int level,
> - unsigned int tag,
> - const char *format,
> - ...) __attribute__((format(printf, 7, 8)));
> + void (*log_printf) (
> + unsigned int rec_ident,
> + const char *function_name,
> + const char *file_name,
> + int file_line,
> + const char *format,
> + ...) __attribute__((format(printf, 5, 6)));
>
> int log_level_security;
> int log_level_error;
> diff --git a/test/logsysrec.c b/test/logsysrec.c
> index 56457ba..5d2163f 100644
> --- a/test/logsysrec.c
> +++ b/test/logsysrec.c
> @@ -56,9 +56,13 @@ int main(int argc, char **argv)
> int i;
>
> for (i = 0; i < 10; i++) {
> - log_printf (LOGSYS_LEVEL_NOTICE, "This is a test of %s\n", "stringparse");
> + log_printf (LOGSYS_LEVEL_NOTICE,
> + "This is a test of %s(%d)\n", "stringparse", i);
>
> - log_rec (LOGREC_ID_CHECKPOINT_CREATE, "record1", 8, "record22", 9, "record333", 10, "record444", 11, LOGSYS_REC_END);
> + log_rec (LOGSYS_ENCODE_RECID(LOGSYS_LEVEL_NOTICE,
> + logsys_subsys_id,
> + LOGREC_ID_CHECKPOINT_CREATE),
> + "record1", 8, "record22", 9, "record333", 10, "record444", 11, LOGSYS_REC_END);
> }
> logsys_log_rec_store ("fdata");
>
> diff --git a/tools/corosync-fplay.c b/tools/corosync-fplay.c
> index e75d239..4a2dc0f 100644
> --- a/tools/corosync-fplay.c
> +++ b/tools/corosync-fplay.c
> @@ -383,14 +383,15 @@ static void logsys_rec_print (const void *record)
> int arg_count = 0;
>
> rec_size = buf_uint32t[rec_idx];
> - level = buf_uint32t[rec_idx+1];
> - rec_ident = buf_uint32t[rec_idx+2];
> - line = buf_uint32t[rec_idx+3];
> - record_number = buf_uint32t[rec_idx+4];
> + rec_ident = buf_uint32t[rec_idx+1];
> + line = buf_uint32t[rec_idx+2];
> + record_number = buf_uint32t[rec_idx+3];
> +
> + level = LOGSYS_DECODE_LEVEL(rec_ident);
>
> printf ("rec=[%d] ", record_number);
> - arg_size_idx = rec_idx + 5;
> - words_processed = 5;
> + arg_size_idx = rec_idx + 4;
> + words_processed = 4;
> for (i = 0; words_processed < rec_size; i++) {
> arguments[arg_count++] =
> (const char *)&buf_uint32t[arg_size_idx + 1];
> @@ -411,7 +412,7 @@ static void logsys_rec_print (const void *record)
> }
> }
>
> - switch(rec_ident) {
> + switch(LOGSYS_DECODE_RECID(rec_ident)) {
> case LOGSYS_RECID_LOG:
> printf ("Log Message=%s\n", arguments[3]);
> break;
> @@ -447,7 +448,7 @@ static void logsys_rec_print (const void *record)
> break;
> default:
> printf ("Unknown record type found subsys=[%s] ident=[%d]\n",
> - arguments[0], rec_ident);
> + arguments[0], LOGSYS_DECODE_RECID(rec_ident));
> break;
> }
> #ifdef COMPILE_OUT
More information about the Openais
mailing list