mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-08-13 14:11:31 +00:00
Clean up tag handling and provide functions to match name with values and
viceversa. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1731 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
parent
51b6b1b6ae
commit
02f9b8e19a
@ -59,6 +59,28 @@
|
||||
|
||||
#include <corosync/engine/logsys.h>
|
||||
|
||||
/* similar to syslog facilities/priorities tables,
|
||||
* make a tag table for internal use
|
||||
*/
|
||||
|
||||
#ifdef SYSLOG_NAMES
|
||||
CODE tagnames[] =
|
||||
{
|
||||
{ "log", LOGSYS_TAG_LOG },
|
||||
{ "enter", LOGSYS_TAG_ENTER },
|
||||
{ "leave", LOGSYS_TAG_LEAVE },
|
||||
{ "trace1", LOGSYS_TAG_TRACE1 },
|
||||
{ "trace2", LOGSYS_TAG_TRACE2 },
|
||||
{ "trace3", LOGSYS_TAG_TRACE3 },
|
||||
{ "trace4", LOGSYS_TAG_TRACE4 },
|
||||
{ "trace5", LOGSYS_TAG_TRACE5 },
|
||||
{ "trace6", LOGSYS_TAG_TRACE6 },
|
||||
{ "trace7", LOGSYS_TAG_TRACE7 },
|
||||
{ "trace8", LOGSYS_TAG_TRACE8 },
|
||||
{ NULL, -1 }
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* These are not static so they can be read from the core file
|
||||
*/
|
||||
@ -908,6 +930,30 @@ const char *logsys_priority_name_get (unsigned int priority)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int logsys_tag_id_get (const char *name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; tagnames[i].c_name != NULL; i++) {
|
||||
if (strcasecmp(name, tagnames[i].c_name) == 0) {
|
||||
return (tagnames[i].c_val);
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
const char *logsys_tag_name_get (unsigned int tag)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; tagnames[i].c_name != NULL; i++) {
|
||||
if (tag == tagnames[i].c_val) {
|
||||
return (tagnames[i].c_name);
|
||||
}
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
unsigned int logsys_config_subsys_set (
|
||||
const char *subsys,
|
||||
unsigned int tags,
|
||||
|
@ -239,31 +239,14 @@ int corosync_main_config_read_logging (
|
||||
char *token = strtok (value, "|");
|
||||
|
||||
while (token != NULL) {
|
||||
if (strcmp (token, "enter") == 0) {
|
||||
logsys_logger.tags |= LOGSYS_TAG_ENTER;
|
||||
} else if (strcmp (token, "leave") == 0) {
|
||||
logsys_logger.tags |= LOGSYS_TAG_LEAVE;
|
||||
} else if (strcmp (token, "trace1") == 0) {
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE1;
|
||||
} else if (strcmp (token, "trace2") == 0) {
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE2;
|
||||
} else if (strcmp (token, "trace3") == 0) {
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE3;
|
||||
} else if (strcmp (token, "trace4") == 0) {
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE4;
|
||||
} else if (strcmp (token, "trace5") == 0) {
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE5;
|
||||
} else if (strcmp (token, "trace6") == 0) {
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE6;
|
||||
} else if (strcmp (token, "trace7") == 0) {
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE7;
|
||||
} else if (strcmp (token, "trace8") == 0) {
|
||||
logsys_logger.tags |= LOGSYS_TAG_TRACE8;
|
||||
} else {
|
||||
int val;
|
||||
|
||||
val = logsys_tag_id_get(token);
|
||||
if (val < 0) {
|
||||
error_reason = "bad tags value";
|
||||
goto parse_error;
|
||||
}
|
||||
|
||||
logsys_logger.tags |= val;
|
||||
token = strtok(NULL, "|");
|
||||
}
|
||||
}
|
||||
|
@ -119,6 +119,12 @@ extern int logsys_priority_id_get (
|
||||
extern const char *logsys_priority_name_get (
|
||||
unsigned int priority);
|
||||
|
||||
extern int logsys_tag_id_get (
|
||||
const char *name);
|
||||
|
||||
extern const char *logsys_tag_name_get (
|
||||
unsigned int tag);
|
||||
|
||||
extern void logsys_fork_completed (void);
|
||||
|
||||
extern void logsys_flush (void);
|
||||
|
Loading…
Reference in New Issue
Block a user