Log: Some cleanup.

Stuff that does not need to be in the header moved to the
implementation file.
This commit is contained in:
Johan Wikman
2015-11-14 23:07:44 +02:00
parent bcb918e60b
commit b8fda016c9
2 changed files with 43 additions and 42 deletions

View File

@ -49,6 +49,35 @@ static const char LOGFILE_NAME_SUFFIX[] = ".log";
extern char *program_invocation_name;
extern char *program_invocation_short_name;
typedef enum
{
BB_READY = 0x00,
BB_FULL,
BB_CLEARED
} blockbuf_state_t;
typedef enum
{
FILEWRITER_INIT,
FILEWRITER_RUN,
FILEWRITER_DONE
} filewriter_state_t;
/**
* UNINIT means zeroed memory buffer allocated for the struct.
* INIT means that struct members may have values, and memory may
* have been allocated. Done function must check and free it.
* RUN Struct is valid for run-time checking.
* DONE means that possible memory allocations have been released.
*/
typedef enum
{
UNINIT = 0,
INIT,
RUN,
DONE
} flat_obj_state_t;
/**
* LOG_FLUSH_NO Do not flush after writing.
* LOG_FLUSH_YES Flush after writing.
@ -124,9 +153,6 @@ ssize_t log_ses_count[LOGFILE_LAST] = {0};
*/
const char* shm_pathname_prefix = "/dev/shm/";
/** Errors are written to syslog too by default */
char* syslog_id_str = strdup("LOGFILE_ERROR");
/** Forward declarations
*/
typedef struct filewriter filewriter_t;

View File

@ -16,10 +16,14 @@
* Copyright MariaDB Corporation Ab 2013-2014
*/
#if !defined(LOG_MANAGER_H)
# define LOG_MANAGER_H
#define LOG_MANAGER_H
#include <syslog.h>
#if defined(__cplusplus)
extern "C" {
#endif
/*
* We need a common.h file that is included by every component.
*/
@ -42,13 +46,6 @@ enum mxs_log_priorities
MXS_LOG_WARNING | MXS_LOG_NOTICE | MXS_LOG_INFO | MXS_LOG_DEBUG),
};
typedef enum
{
BB_READY = 0x00,
BB_FULL,
BB_CLEARED
} blockbuf_state_t;
typedef enum
{
LOGFILE_ERROR = 1,
@ -59,13 +56,6 @@ typedef enum
LOGFILE_LAST = LOGFILE_DEBUG
} logfile_id_t;
typedef enum
{
FILEWRITER_INIT,
FILEWRITER_RUN,
FILEWRITER_DONE
} filewriter_state_t;
typedef enum
{
LOG_TARGET_DEFAULT = 0,
@ -87,6 +77,11 @@ typedef struct log_info
#define LT LOGFILE_TRACE
#define LD LOGFILE_DEBUG
extern int lm_enabled_priorities_bitmask;
extern int lm_enabled_logfiles_bitmask;
extern ssize_t log_ses_count[];
extern __thread log_info_t tls_log_info;
/**
* Check if specified log type is enabled in general or if it is enabled
* for the current session.
@ -107,21 +102,6 @@ typedef struct log_info
cmd; \
}
/**
* UNINIT means zeroed memory buffer allocated for the struct.
* INIT means that struct members may have values, and memory may
* have been allocated. Done function must check and free it.
* RUN Struct is valid for run-time checking.
* DONE means that possible memory allocations have been released.
*/
typedef enum
{
UNINIT = 0,
INIT,
RUN,
DONE
} flat_obj_state_t;
/**
* LOG_AUGMENT_WITH_FUNCTION Each logged line is suffixed with [function-name].
*/
@ -131,13 +111,6 @@ typedef enum
LOG_AUGMENTATION_MASK = (LOG_AUGMENT_WITH_FUNCTION)
} log_augmentation_t;
EXTERN_C_BLOCK_BEGIN
extern int lm_enabled_priorities_bitmask;
extern int lm_enabled_logfiles_bitmask;
extern ssize_t log_ses_count[];
extern __thread log_info_t tls_log_info;
bool mxs_log_init(const char* ident, const char* logdir, log_target_t target);
void mxs_log_finish(void);
@ -169,8 +142,6 @@ inline int mxs_log_id_to_priority(logfile_id_t id)
#define skygw_log_write_flush(id, format, ...) skygw_log_write(id, format, ##__VA_ARGS__)
EXTERN_C_BLOCK_END
/**
* Helper, not to be called directly.
*/
@ -189,4 +160,8 @@ EXTERN_C_BLOCK_END
#define MXS_INFO(format, ...) MXS_LOG_MESSAGE(LOG_INFO, format, ##__VA_ARGS__)
#define MXS_DEBUG(format, ...) MXS_LOG_MESSAGE(LOG_DEBUG, format, ##__VA_ARGS__)
#if defined(__cplusplus)
}
#endif
#endif /** LOG_MANAGER_H */