mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Polishing:
- change some return types from int to bool; - add [ERROR] tag to log_error() output; - add [INFO] tag to log_info() output; - change log messages to be more consistent. server-tools/instance-manager/IMService.cpp: Log polishing. server-tools/instance-manager/commands.cc: Log polishing. server-tools/instance-manager/commands.h: Eliminate warnings. server-tools/instance-manager/instance.cc: Log polishing. server-tools/instance-manager/instance_map.cc: Log polishing. server-tools/instance-manager/instance_options.cc: 1) Log polishing. 2) Change int-return type to bool. server-tools/instance-manager/instance_options.h: Change int-return type to bool. server-tools/instance-manager/listener.cc: Log polishing. server-tools/instance-manager/log.cc: Log polishing. server-tools/instance-manager/log.h: Log polishing. server-tools/instance-manager/manager.cc: Log polishing. server-tools/instance-manager/mysql_connection.cc: Log polishing. server-tools/instance-manager/mysql_connection.h: Change int-return type to bool. server-tools/instance-manager/mysqlmanager.cc: Log polishing. server-tools/instance-manager/priv.cc: Log polishing. server-tools/instance-manager/thread_registry.cc: 1. Print pthread_t as (unsigned long), not as (signed long) to avoid negative identifiers in output. 2. Print thread id after it will be initialized, not before. server-tools/instance-manager/user_map.cc: Log polishing.
This commit is contained in:
@ -37,7 +37,8 @@
|
||||
log()
|
||||
*/
|
||||
|
||||
static inline void log(FILE *file, const char *format, va_list args)
|
||||
static void log(FILE *file,const char *level_tag, const char *format,
|
||||
va_list args)
|
||||
{
|
||||
/*
|
||||
log() should be thread-safe; it implies that we either call fprintf()
|
||||
@ -53,15 +54,16 @@ static inline void log(FILE *file, const char *format, va_list args)
|
||||
localtime_r(&now, &bd_time);
|
||||
|
||||
char buff_date[128];
|
||||
sprintf(buff_date, "[%d/%lu] [%02d/%02d/%02d %02d:%02d:%02d] ",
|
||||
sprintf(buff_date, "[%d/%lu] [%02d/%02d/%02d %02d:%02d:%02d] [%s] ",
|
||||
(int) getpid(),
|
||||
(unsigned long) pthread_self(),
|
||||
bd_time.tm_year % 100,
|
||||
bd_time.tm_mon + 1,
|
||||
bd_time.tm_mday,
|
||||
bd_time.tm_hour,
|
||||
bd_time.tm_min,
|
||||
bd_time.tm_sec);
|
||||
(int) bd_time.tm_year % 100,
|
||||
(int) bd_time.tm_mon + 1,
|
||||
(int) bd_time.tm_mday,
|
||||
(int) bd_time.tm_hour,
|
||||
(int) bd_time.tm_min,
|
||||
(int) bd_time.tm_sec,
|
||||
(const char *) level_tag);
|
||||
/* Format the message */
|
||||
char buff_stack[256];
|
||||
|
||||
@ -109,46 +111,15 @@ static inline void log(FILE *file, const char *format, va_list args)
|
||||
/* don't fflush() the file: buffering strategy is set in log_init() */
|
||||
}
|
||||
|
||||
|
||||
void log_error(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
log(stderr, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
void log_info(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
log(stdout, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
/* TODO: rewrite with buffering print */
|
||||
void print_info(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vfprintf(stdout, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void print_error(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
/**************************************************************************
|
||||
Logging: implementation of public interface.
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
The function initializes logging sub-system.
|
||||
|
||||
SYNOPSIS
|
||||
log_init()
|
||||
RETURN VALUE
|
||||
0 ok
|
||||
!0 error
|
||||
*/
|
||||
|
||||
void log_init()
|
||||
@ -161,6 +132,53 @@ void log_init()
|
||||
setbuf(stdout, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The function is intended to log error messages. It precedes a message
|
||||
with date, time and [ERROR] tag and print it to the stderr.
|
||||
|
||||
SYNOPSIS
|
||||
log_error()
|
||||
format [IN] format string
|
||||
... [IN] arguments to format
|
||||
*/
|
||||
|
||||
void log_error(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
log(stderr, "ERROR", format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The function is intended to log information messages. It precedes
|
||||
a message with date, time and [INFO] tag and print it to the stdout.
|
||||
|
||||
SYNOPSIS
|
||||
log_error()
|
||||
format [IN] format string
|
||||
... [IN] arguments to format
|
||||
*/
|
||||
|
||||
void log_info(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
log(stdout, "INFO", format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
/*
|
||||
The function prints information to the error log and eixt(1).
|
||||
|
||||
SYNOPSIS
|
||||
die()
|
||||
format [IN] format string
|
||||
... [IN] arguments to format
|
||||
*/
|
||||
|
||||
void die(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
Reference in New Issue
Block a user