8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 23:23:04 +01:00

Make syslog interface as light as possible

This commit is contained in:
alexpeshkoff 2008-01-31 12:05:08 +00:00
parent 1cc2f4be32
commit a4aac986f8
4 changed files with 12 additions and 11 deletions

View File

@ -178,7 +178,7 @@ void ConfigFile::loadConfig()
{
Firebird::string Msg = "Missing configuration file: " +
configFile.ToString() + ", exiting";
Firebird::Syslog::Record(Firebird::Syslog::Error, Msg);
Firebird::Syslog::Record(Firebird::Syslog::Error, Msg.c_str());
Firebird::fatal_exception::raise(Msg.c_str());
}
#endif //EXCEPTION_ON_NO_CONF
@ -204,7 +204,7 @@ void ConfigFile::loadConfig()
inputLine + "\"").ToString();
Firebird::Syslog::Record(fExceptionOnError ?
Firebird::Syslog::Error :
Firebird::Syslog::Warning, Msg);
Firebird::Syslog::Warning, Msg.c_str());
#ifdef EXCEPTION_ON_NO_CONF
BadLinesCount++;
#endif

View File

@ -29,7 +29,7 @@ namespace Firebird {
class Syslog {
public:
enum Severity {Warning, Error};
static void Record(Severity, const string&);
static void Record(Severity, const char*);
};
} // namespace Firebird

View File

@ -24,9 +24,10 @@
#include <syslog.h>
#include <unistd.h>
#include <string.h>
namespace Firebird {
void Syslog::Record(Severity level, const string& Msg)
void Syslog::Record(Severity level, const char* Msg)
{
int priority = LOG_ERR;
switch (level) {
@ -38,7 +39,7 @@ void Syslog::Record(Severity level, const string& Msg)
priority = LOG_ERR;
break;
}
syslog(priority | LOG_LOCAL3, "%s (%m)", Msg.c_str());
syslog(priority | LOG_LOCAL3, "%s (%m)", Msg);
// try to put it also on controlling tty
int fd = 2;
@ -48,7 +49,7 @@ void Syslog::Record(Severity level, const string& Msg)
}
if (isatty(fd))
{
write(fd, Msg.c_str(), Msg.length());
write(fd, Msg, strlen(Msg));
write(fd, "\n", 1);
}
}

View File

@ -56,10 +56,10 @@ public:
~SyslogAccess() {
DeleteCriticalSection(&cs);
}
void Record(WORD wType, const Firebird::string& Msg);
void Record(WORD wType, const char* Msg);
};
void SyslogAccess::Record(WORD wType, const Firebird::string& Msg)
void SyslogAccess::Record(WORD wType, const char* Msg)
{
EnterCriticalSection(&cs);
if (! InitFlag) {
@ -75,13 +75,13 @@ void SyslogAccess::Record(WORD wType, const Firebird::string& Msg)
bool use9x = true;
if (LogHandle) {
LPCTSTR sb[1];
sb[0] = Msg.c_str();
sb[0] = Msg;
if (fReportEvent(LogHandle, wType, 0, 0, 0, 1, 0, sb, 0)) {
use9x = false;
}
}
if (use9x) {
::MessageBox(0, Msg.c_str(), "Firebird Error", MB_ICONSTOP);
::MessageBox(0, Msg, "Firebird Error", MB_ICONSTOP);
}
LeaveCriticalSection(&cs);
}
@ -92,7 +92,7 @@ Firebird::InitInstance<SyslogAccess> iSyslogAccess;
namespace Firebird {
void Syslog::Record(Severity level, const Firebird::string& Msg)
void Syslog::Record(Severity level, const char* Msg)
{
WORD wType = EVENTLOG_ERROR_TYPE;
switch (level) {