1
/* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
3
* PrimeBase Media Stream for MySQL
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
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.
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
19
* Original author: Paul McCullagh (H&G2JCtL)
20
* Continued development: Barry Leslie
25
* General logging class
42
static const int Protocol = 0;
43
static const int Error = 1;
44
static const int Warning = 2;
45
static const int Trace = 3;
47
CSLog(FILE *s, int level):
53
pthread_mutex_init(&iMutex, NULL);
54
memset(&iLockThread, 0, sizeof(iLockThread));
58
memset(&iLockThread, 0, sizeof(iLockThread));
60
pthread_mutex_destroy(&iMutex);
64
pthread_t thd = pthread_self();
66
if (iLockCount > 0 && pthread_equal(iLockThread, thd))
69
pthread_mutex_lock(&iMutex);
79
pthread_mutex_unlock(&iMutex);
83
void getNow(char *buffer, size_t len);
84
void log(CSThread *self, const char *func, const char *file, int line, int level, const char* buffer);
85
void log(CSThread *self, int level, const char*);
86
void log(CSThread *self, int level, CSString&);
87
void log(CSThread *self, int level, CSString*);
88
void log(CSThread *self, int level, int);
89
void eol(CSThread *self, int level);
91
void logLine(CSThread *self, int level, const char *buffer);
92
void log_va(CSThread *self, int level, const char *func, const char *file, int line, const char *fmt, va_list ap);
93
void logf(CSThread *self, int level, const char *fmt, ...);
94
void logf(CSThread *self, int level, const char *func, const char *file, int line, const char *fmt, ...);
96
void flush() {fflush(iStream);}
98
/* Write out a logging header: */
99
void header(CSThread *self, const char *func, const char *file, int line, int level);
101
/* The output stream: */
104
bool iHeaderPending; /* True if we must write a header before the next text. */
106
int iLogLevel; /* The current log level. */
108
pthread_t iLockThread;
110
pthread_mutex_t iMutex;