17
23
for other messages set to 0
18
24
@param msg message text
26
@note It should be possible to use this method (and other error reporting
27
methods relying on it) right after creation of the Logger object instance.
28
The message should be written to these destinations which are available at
29
the moment. Destinations which are not ready/initialized yet should be
20
32
@returns 0 on success.
22
34
int Logger::write_message(log_level::value level, int error_code,
25
const char *prefix= m_type == BACKUP ? "Backup" : "Restore";
26
37
char buf[ERRMSGSIZE + 30];
28
my_snprintf(buf,sizeof(buf),"%s: %s",prefix,msg);
40
if (m_state == READY || m_state == RUNNING)
42
my_snprintf(buf, sizeof(buf), "%s: %s",
43
m_type == BACKUP ? "Backup" : "Restore" , msg);
31
48
case log_level::ERROR:
33
errors.push_front(new MYSQL_ERROR(::current_thd,error_code,
34
MYSQL_ERROR::WARN_LEVEL_ERROR,msg));
50
errors.push_front(new MYSQL_ERROR(::current_thd, error_code,
51
MYSQL_ERROR::WARN_LEVEL_ERROR, msg));
36
53
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
38
DBUG_PRINT("backup_log",("[ERROR] %s",buf));
55
DBUG_PRINT("backup_log",("[ERROR] %s", out));
57
if (m_state == READY || m_state == RUNNING)
58
report_ob_error(m_thd, m_op_id, error_code);
41
62
case log_level::WARNING:
42
sql_print_warning(buf);
63
sql_print_warning(out);
43
64
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
45
DBUG_PRINT("backup_log",("[Warning] %s",buf));
66
DBUG_PRINT("backup_log",("[Warning] %s", out));
48
69
case log_level::INFO:
49
sql_print_information(buf);
50
DBUG_PRINT("backup_log",("[Info] %s",buf));
70
sql_print_information(out);
71
DBUG_PRINT("backup_log",("[Info] %s", out));
53
74
default: return ERROR;
68
89
int Logger::v_report_error(log_level::value level, int error_code, va_list args)
70
return v_write_message(level,error_code,ER_SAFE(error_code),args);
91
return v_write_message(level, error_code, ER_SAFE(error_code), args);
83
104
char buf[ERRMSGSIZE + 20];
85
my_vsnprintf(buf,sizeof(buf),format,args);
86
return write_message(level,error_code,buf);
106
my_vsnprintf(buf, sizeof(buf), format, args);
107
return write_message(level, error_code, buf);
111
Report statistics from backup/restore catalogue before the main operation
114
void Logger::report_stats_pre(const Image_info &info)
116
DBUG_ASSERT(m_state == RUNNING);
118
report_ob_num_objects(m_thd, m_op_id, info.table_count());
122
Report statistics from backup/restore catalogue after the operation is
125
void Logger::report_stats_post(const Image_info &info)
127
DBUG_ASSERT(m_state == RUNNING);
129
report_ob_size(m_thd, m_op_id, info.data_size);
90
132
} // backup namespace