mirror of https://github.com/yandex/odyssey.git
odissey: new naming scheme: od_syslog_t
This commit is contained in:
parent
3e00c8020e
commit
cc70b75d22
10
core/od.h
10
core/od.h
|
@ -10,11 +10,11 @@
|
|||
typedef struct od_t od_t;
|
||||
|
||||
struct od_t {
|
||||
od_pid_t pid;
|
||||
odsyslog_t syslog;
|
||||
odlog_t log;
|
||||
odconfig_t config;
|
||||
odscheme_t scheme;
|
||||
od_pid_t pid;
|
||||
od_syslog_t syslog;
|
||||
odlog_t log;
|
||||
odconfig_t config;
|
||||
odscheme_t scheme;
|
||||
};
|
||||
|
||||
void od_init(od_t*);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "od_syslog.h"
|
||||
#include "od_log.h"
|
||||
|
||||
int od_loginit(odlog_t *l, od_pid_t *pid, odsyslog_t *syslog)
|
||||
int od_loginit(odlog_t *l, od_pid_t *pid, od_syslog_t *syslog)
|
||||
{
|
||||
l->pid = pid;
|
||||
l->syslog = syslog;
|
||||
|
@ -49,7 +49,7 @@ int od_logclose(odlog_t *l)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int od_logv(odlog_t *l, odsyslog_prio_t prio,
|
||||
int od_logv(odlog_t *l, od_syslogprio_t prio,
|
||||
char *ident,
|
||||
char *fmt, va_list args)
|
||||
{
|
||||
|
|
|
@ -11,14 +11,14 @@ typedef struct odlog_t odlog_t;
|
|||
|
||||
struct odlog_t {
|
||||
od_pid_t *pid;
|
||||
odsyslog_t *syslog;
|
||||
od_syslog_t *syslog;
|
||||
int fd;
|
||||
};
|
||||
|
||||
int od_loginit(odlog_t*, od_pid_t*, odsyslog_t*);
|
||||
int od_loginit(odlog_t*, od_pid_t*, od_syslog_t*);
|
||||
int od_logopen(odlog_t*, char*);
|
||||
int od_logclose(odlog_t*);
|
||||
int od_logv(odlog_t*, odsyslog_prio_t, char*, char*, va_list);
|
||||
int od_logv(odlog_t*, od_syslogprio_t, char*, char*, va_list);
|
||||
|
||||
static inline int
|
||||
od_log(odlog_t *l, char *fmt, ...)
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
#include "od_macro.h"
|
||||
#include "od_syslog.h"
|
||||
|
||||
typedef struct odsyslog_facility_t odsyslog_facility_t;
|
||||
typedef struct od_syslog_facility_t od_syslog_facility_t;
|
||||
|
||||
struct odsyslog_facility_t {
|
||||
struct od_syslog_facility_t {
|
||||
char *name;
|
||||
int id;
|
||||
};
|
||||
|
||||
odsyslog_facility_t od_syslog_facilities[] =
|
||||
od_syslog_facility_t od_syslog_facilities[] =
|
||||
{
|
||||
{ "daemon", LOG_DAEMON },
|
||||
{ "user", LOG_USER },
|
||||
|
@ -49,12 +49,12 @@ static int od_syslog_prio[] = {
|
|||
LOG_INFO, LOG_ERR, LOG_DEBUG
|
||||
};
|
||||
|
||||
int od_syslog_open(odsyslog_t *slog, char *ident, char *facility)
|
||||
int od_syslog_open(od_syslog_t *slog, char *ident, char *facility)
|
||||
{
|
||||
int facility_id = LOG_DAEMON;
|
||||
if (facility) {
|
||||
int i = 0;
|
||||
odsyslog_facility_t *facility_ptr;
|
||||
od_syslog_facility_t *facility_ptr;
|
||||
for (;;) {
|
||||
facility_ptr = &od_syslog_facilities[i];
|
||||
if (facility_ptr->name == NULL)
|
||||
|
@ -73,14 +73,14 @@ int od_syslog_open(odsyslog_t *slog, char *ident, char *facility)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void od_syslog_close(odsyslog_t *slog)
|
||||
void od_syslog_close(od_syslog_t *slog)
|
||||
{
|
||||
if (! slog->in_use)
|
||||
return;
|
||||
closelog();
|
||||
}
|
||||
|
||||
void od_syslog(odsyslog_t *slog, odsyslog_prio_t prio, char *msg)
|
||||
void od_syslog(od_syslog_t *slog, od_syslogprio_t prio, char *msg)
|
||||
{
|
||||
if (slog->in_use)
|
||||
syslog(od_syslog_prio[prio], "%s", msg);
|
||||
|
|
|
@ -7,25 +7,25 @@
|
|||
* PostgreSQL connection pooler and request router.
|
||||
*/
|
||||
|
||||
typedef struct odsyslog_t odsyslog_t;
|
||||
typedef struct od_syslog_t od_syslog_t;
|
||||
|
||||
typedef enum {
|
||||
OD_SYSLOG_INFO,
|
||||
OD_SYSLOG_ERROR,
|
||||
OD_SYSLOG_DEBUG
|
||||
} odsyslog_prio_t;
|
||||
} od_syslogprio_t;
|
||||
|
||||
struct odsyslog_t {
|
||||
struct od_syslog_t {
|
||||
int in_use;
|
||||
};
|
||||
|
||||
static inline void
|
||||
od_syslog_init(odsyslog_t *syslog) {
|
||||
od_syslog_init(od_syslog_t *syslog) {
|
||||
syslog->in_use = 0;
|
||||
}
|
||||
|
||||
int od_syslog_open(odsyslog_t*, char*, char*);
|
||||
void od_syslog_close(odsyslog_t*);
|
||||
void od_syslog(odsyslog_t*, odsyslog_prio_t, char*);
|
||||
int od_syslog_open(od_syslog_t*, char*, char*);
|
||||
void od_syslog_close(od_syslog_t*);
|
||||
void od_syslog(od_syslog_t*, od_syslogprio_t, char*);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue