~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/replication/reporting.cc

  • Committer: Brian Aker
  • Date: 2009-01-07 21:26:58 UTC
  • Revision ID: brian@tangent.org-20090107212658-2fh0s2uwh10w68y2
Committing fix lock_multi

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
#include <drizzled/server_includes.h>
 
21
#include <drizzled/replication/reporting.h>
 
22
#include <drizzled/gettext.h>
 
23
#include <drizzled/errmsg_print.h>
 
24
 
 
25
void
 
26
Slave_reporting_capability::report(loglevel level, int err_code,
 
27
                                   const char *msg, ...) const
 
28
{
 
29
  char buff[MAX_SLAVE_ERRMSG];
 
30
  char *pbuff= buff;
 
31
  uint32_t pbuffsize= sizeof(buff);
 
32
  va_list args;
 
33
 
 
34
  /*
 
35
    If it is an error,
 
36
    it must be reported in Last_error and Last_errno in
 
37
    SHOW SLAVE STATUS.
 
38
  */
 
39
 
 
40
  if (level == ERROR_LEVEL)
 
41
  {
 
42
    pbuff= m_last_error.message;
 
43
    pbuffsize= sizeof(m_last_error.message);
 
44
    m_last_error.number= err_code;
 
45
  }
 
46
 
 
47
  va_start(args, msg);
 
48
  vsnprintf(pbuff, pbuffsize, msg, args);
 
49
  va_end(args);
 
50
 
 
51
  /* If the msg string ends with '.', do not add a ',' it would be ugly */
 
52
  /* todo: check type loglevel against errmsg priority */
 
53
  errmsg_printf((int) level,
 
54
                _("Slave %s: %s%s Error_code: %d"),
 
55
                m_thread_name, pbuff,
 
56
                (pbuff[0] && *(strchr(pbuff, '\0')-1) == '.') ? "" : ",",
 
57
                err_code);
 
58
}