~ubuntu-branches/ubuntu/vivid/mariadb-5.5/vivid

« back to all changes in this revision

Viewing changes to plugin/sql_errlog/service_logger.h

  • Committer: Package Import Robot
  • Author(s): James Page, Otto Kekäläinen
  • Date: 2014-02-17 16:51:52 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140217165152-k315d3175g865kkx
Tags: 5.5.35-1
[ Otto Kekäläinen ]
* New upstream release, fixing the following security issues:
  - Buffer overflow in client/mysql.cc (Closes: #737597).
    - CVE-2014-0001
  - http://www.oracle.com/technetwork/topics/security/cpujan2014-1972949.html
    - CVE-2013-5891
    - CVE-2013-5908
    - CVE-2014-0386
    - CVE-2014-0393
    - CVE-2014-0401
    - CVE-2014-0402
    - CVE-2014-0412
    - CVE-2014-0420
    - CVE-2014-0437
* Upstream https://mariadb.atlassian.net/browse/MDEV-4902
  fixes compatibility with Bison 3.0 (Closes: #733002)
* Updated Russian debconf translation (Closes: #734426)
* Updated Japanese debconf translation (Closes: #735284)
* Updated French debconf translation (Closes: #736480)
* Renamed SONAME properly (Closes: #732967)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2012 Monty Program Ab
2
 
 
3
 
   This program is free software; you can redistribute it and/or modify
4
 
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; version 2 of the License.
6
 
 
7
 
   This program is distributed in the hope that it will be useful,
8
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
   GNU General Public License for more details.
11
 
 
12
 
   You should have received a copy of the GNU General Public License
13
 
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
 
 
16
 
#ifndef MYSQL_SERVICE_LOGGER_INCLUDED
17
 
#define MYSQL_SERVICE_LOGGER_INCLUDED
18
 
 
19
 
#ifndef MYSQL_ABI_CHECK
20
 
#include <stdarg.h>
21
 
#endif
22
 
 
23
 
/**
24
 
  @file
25
 
  logger service
26
 
 
27
 
  Log file with rotation implementation.
28
 
 
29
 
  This service implements logging with possible rotation
30
 
  of the log files. Interface intentionally tries to be similar to FILE*
31
 
  related functions.
32
 
 
33
 
  So that one can open the log with logger_open(), specifying
34
 
  the limit on the logfile size and the rotations number.
35
 
 
36
 
  Then it's possible to write messages to the log with
37
 
  logger_printf or logger_vprintf functions.
38
 
 
39
 
  As the size of the logfile grows over the specified limit,
40
 
  it is renamed to 'logfile.1'. The former 'logfile.1' becomes
41
 
  'logfile.2', etc. The file 'logfile.rotations' is removed.
42
 
  That's how the rotation works.
43
 
 
44
 
  The rotation can be forced with the logger_rotate() call.
45
 
 
46
 
  Finally the log should be closed with logger_close().
47
 
 
48
 
@notes:
49
 
  Implementation checks the size of the log file before it starts new
50
 
  printf into it. So the size of the file gets over the limit when it rotates.
51
 
 
52
 
  The access is secured with the mutex, so the log is threadsafe.
53
 
*/
54
 
 
55
 
 
56
 
#ifdef __cplusplus
57
 
extern "C" {
58
 
#endif
59
 
 
60
 
typedef struct logger_handle_st LOGGER_HANDLE;
61
 
 
62
 
extern struct logger_service_st {
63
 
  LOGGER_HANDLE* (*open)(const char *path,
64
 
                         unsigned long long size_limit,
65
 
                         unsigned int rotations);
66
 
  int (*close)(LOGGER_HANDLE *log);
67
 
  int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
68
 
  int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...);
69
 
  int (*rotate)(LOGGER_HANDLE *log);
70
 
} *logger_service;
71
 
 
72
 
#if 0 /*MYSQL_DYNAMIC_PLUGIN*/
73
 
 
74
 
#define logger_open(path, size_limit, rotations) \
75
 
  (logger_service->open(path, size_limit, rotations))
76
 
#define logger_close(log) (logger_service->close(log))
77
 
#define logger_rotate(log) (logger_service->rotate(log))
78
 
#define logger_vprintf(log, fmt, argptr) (logger_service->\
79
 
    vprintf(log, fmt, argptr))
80
 
#define logger_printf logger_service->printf
81
 
#else
82
 
 
83
 
  LOGGER_HANDLE *logger_open(const char *path,
84
 
                             unsigned long long size_limit,
85
 
                             unsigned int rotations);
86
 
  int logger_close(LOGGER_HANDLE *log);
87
 
  int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
88
 
  int logger_rotate(LOGGER_HANDLE *log); 
89
 
  int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
90
 
 
91
 
  void init_logger_mutexes();
92
 
#endif
93
 
 
94
 
 
95
 
#ifdef __cplusplus
96
 
}
97
 
#endif
98
 
 
99
 
#endif /*MYSQL_SERVICE_LOGGER_INCLUDED*/
100