#include "log.h"#include <my_global.h>#include <m_string.h>#include <my_sys.h>#include <stdarg.h>#include "portability.h"Include dependency graph for log.cc:

Go to the source code of this file.
Functions | |
| static void | log (FILE *file, const char *format, va_list args) |
| void | log_error (const char *format,...) |
| void | log_info (const char *format,...) |
| void | print_info (const char *format,...) |
| void | print_error (const char *format,...) |
| void | log_init () |
| void | die (const char *format,...) |
| void die | ( | const char * | format, | |
| ... | ||||
| ) |
| static void log | ( | FILE * | file, | |
| const char * | format, | |||
| va_list | args | |||
| ) | [inline, static] |
Definition at line 40 of file log.cc.
References DBUG_ASSERT, localtime_r(), my_free, my_malloc(), MYF, n, strmake(), and TRUE.
Referenced by check_binlog_magic(), TaoCrypt::DiscreteLogWorkFactor(), get_best_covering_ror_intersect(), get_best_disjunct_quick(), get_merge_buffers_cost(), log2_n_fact(), log_checkpoint_margin(), log_close(), log_error(), log_flush_margin(), log_info(), log_reserve_and_open(), log_write_low(), open_binlog(), Item_func_log2::val_real(), Item_func_log::val_real(), and Item_func_ln::val_real().
00041 { 00042 /* 00043 log() should be thread-safe; it implies that we either call fprintf() 00044 once per log(), or use flockfile()/funlockfile(). But flockfile() is 00045 POSIX, not ANSI C, so we try to vsnprintf the whole message to the 00046 stack, and if stack buffer is not enough, to malloced string. When 00047 message is formatted, it is fprintf()'ed to the file. 00048 */ 00049 00050 /* Format time like MYSQL_LOG does. */ 00051 time_t now= time(0); 00052 struct tm bd_time; // broken-down time 00053 localtime_r(&now, &bd_time); 00054 00055 char buff_date[32]; 00056 sprintf(buff_date, "%02d%02d%02d %2d:%02d:%02d\t", 00057 bd_time.tm_year % 100, 00058 bd_time.tm_mon + 1, 00059 bd_time.tm_mday, 00060 bd_time.tm_hour, 00061 bd_time.tm_min, 00062 bd_time.tm_sec); 00063 /* Format the message */ 00064 char buff_stack[256]; 00065 00066 int n= vsnprintf(buff_stack, sizeof(buff_stack), format, args); 00067 /* 00068 return value of vsnprintf can vary, according to various standards; 00069 try to check all cases. 00070 */ 00071 char *buff_msg= buff_stack; 00072 if (n < 0 || n == sizeof(buff_stack)) 00073 { 00074 int size= sizeof(buff_stack) * 2; 00075 buff_msg= (char*) my_malloc(size, MYF(0)); 00076 while (TRUE) 00077 { 00078 if (buff_msg == 0) 00079 { 00080 strmake(buff_stack, "log(): message is too big, my_malloc() failed", 00081 sizeof(buff_stack) - 1); 00082 buff_msg= buff_stack; 00083 break; 00084 } 00085 n = vsnprintf(buff_msg, size, format, args); 00086 if (n >= 0 && n < size) 00087 break; 00088 size*= 2; 00089 /* realloc() does unnecessary memcpy */ 00090 my_free(buff_msg, 0); 00091 buff_msg= (char*) my_malloc(size, MYF(0)); 00092 } 00093 } 00094 else if ((size_t) n > sizeof(buff_stack)) 00095 { 00096 buff_msg= (char*) my_malloc(n + 1, MYF(0)); 00097 #ifdef DBUG 00098 DBUG_ASSERT(n == vsnprintf(buff_msg, n + 1, format, args)); 00099 #else 00100 vsnprintf(buff_msg, n + 1, format, args); 00101 #endif 00102 } 00103 fprintf(file, "%s%s\n", buff_date, buff_msg); 00104 if (buff_msg != buff_stack) 00105 my_free(buff_msg, 0); 00106 00107 /* don't fflush() the file: buffering strategy is set in log_init() */ 00108 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void log_error | ( | const char * | format, | |
| ... | ||||
| ) |
Definition at line 111 of file log.cc.
Referenced by angel(), check_user(), Instance_map::complete_initialization(), Abstract_option_cmd::correct_file(), Instance_map::create_instance(), create_instance_in_file(), create_pid_file(), Listener_thread::create_tcp_socket(), Listener_thread::create_unix_socket(), LOGGER::error_log_print(), Drop_instance::execute_impl(), Instance_options::fill_instance_version(), Instance_options::fill_mysqld_real_path(), Listener_thread::handle_new_mysql_connection(), Instance::kill_instance(), manager(), Set_option::process_option(), Instance::remove_pid(), Listener_thread::run(), set_user(), and Instance::start().
00112 { 00113 va_list args; 00114 va_start(args, format); 00115 log(stderr, format, args); 00116 va_end(args); 00117 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void log_info | ( | const char * | format, | |
| ... | ||||
| ) |
Definition at line 120 of file log.cc.
Referenced by angel(), check_user(), Instance_map::create_instance(), Listener_thread::create_tcp_socket(), Listener_thread::create_unix_socket(), Mysql_connection_thread::dispatch_command(), Mysql_connection_thread::do_command(), HandleServiceOptions(), User::init(), Instance::is_running(), User_map::load(), Options::load(), Instance_map::load(), IMService::Log(), manager(), mysql_connection(), Guardian_thread::process_instance(), Instance_map::process_one_option(), Mysql_connection_thread::run(), Listener_thread::run(), start_and_monitor_instance(), and start_process().
00121 { 00122 va_list args; 00123 va_start(args, format); 00124 log(stdout, format, args); 00125 va_end(args); 00126 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void log_init | ( | void | ) |
Definition at line 152 of file log.cc.
Referenced by init_environment(), and innobase_start_or_create_for_mysql().
00153 { 00154 /* 00155 stderr is unbuffered by default; there is no good of line buffering, 00156 as all logging is performed linewise - so remove buffering from stdout 00157 also 00158 */ 00159 setbuf(stdout, 0); 00160 }
Here is the caller graph for this function:

| void print_error | ( | const char * | format, | |
| ... | ||||
| ) |
Definition at line 137 of file log.cc.
Referenced by create_record(), get_one_option(), and get_options().
00138 { 00139 va_list args; 00140 va_start(args, format); 00141 vfprintf(stderr, format, args); 00142 va_end(args); 00143 }
Here is the caller graph for this function:

| void print_info | ( | const char * | format, | |
| ... | ||||
| ) |
1.4.7

