~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#include "mysql_priv.h"
2
#include "rpl_reporting.h"
3
4
void
5
Slave_reporting_capability::report(loglevel level, int err_code,
6
                                   const char *msg, ...) const
7
{
8
  void (*report_function)(const char *, ...);
9
  char buff[MAX_SLAVE_ERRMSG];
10
  char *pbuff= buff;
11
  uint pbuffsize= sizeof(buff);
12
  va_list args;
13
  va_start(args, msg);
14
15
  switch (level)
16
  {
17
  case ERROR_LEVEL:
18
    /*
19
      It's an error, it must be reported in Last_error and Last_errno in SHOW
20
      SLAVE STATUS.
21
    */
22
    pbuff= m_last_error.message;
23
    pbuffsize= sizeof(m_last_error.message);
24
    m_last_error.number = err_code;
25
    report_function= sql_print_error;
26
    break;
27
  case WARNING_LEVEL:
28
    report_function= sql_print_warning;
29
    break;
30
  case INFORMATION_LEVEL:
31
    report_function= sql_print_information;
32
    break;
33
  default:
34
    DBUG_ASSERT(0);                            // should not come here
35
    return;          // don't crash production builds, just do nothing
36
  }
37
38
  vsnprintf(pbuff, pbuffsize, msg, args);
77.1.18 by Monty Taylor
Removed my_vsnprintf and my_snprintf.
39
1 by brian
clean slate
40
  va_end(args);
41
42
  /* If the msg string ends with '.', do not add a ',' it would be ugly */
43
  report_function("Slave %s: %s%s Error_code: %d",
44
                  m_thread_name, pbuff,
45
                  (pbuff[0] && *(strend(pbuff)-1) == '.') ? "" : ",",
46
                  err_code);
47
}
48