Fixed compilation on Windows.

This commit is contained in:
Gunnar Beutner 2012-07-10 15:44:59 +02:00
parent a64c99c176
commit ffd884a6ab
6 changed files with 34 additions and 2 deletions

View File

@ -18,11 +18,14 @@
<ClCompile Include="event.cpp" />
<ClCompile Include="exception.cpp" />
<ClCompile Include="fifo.cpp" />
<ClCompile Include="logger.cpp" />
<ClCompile Include="object.cpp" />
<ClCompile Include="objectmap.cpp" />
<ClCompile Include="objectset.cpp" />
<ClCompile Include="ringbuffer.cpp" />
<ClCompile Include="socket.cpp" />
<ClCompile Include="streamlogger.cpp" />
<ClCompile Include="sysloglogger.cpp" />
<ClCompile Include="tcpclient.cpp" />
<ClCompile Include="tcpserver.cpp" />
<ClCompile Include="tcpsocket.cpp" />
@ -40,6 +43,7 @@
<ClInclude Include="configobject.h" />
<ClInclude Include="dictionary.h" />
<ClInclude Include="event.h" />
<ClInclude Include="logger.h" />
<ClInclude Include="objectmap.h" />
<ClInclude Include="objectset.h" />
<ClInclude Include="exception.h" />
@ -48,6 +52,8 @@
<ClInclude Include="object.h" />
<ClInclude Include="ringbuffer.h" />
<ClInclude Include="socket.h" />
<ClInclude Include="streamlogger.h" />
<ClInclude Include="sysloglogger.h" />
<ClInclude Include="tcpclient.h" />
<ClInclude Include="tcpserver.h" />
<ClInclude Include="tcpsocket.h" />

View File

@ -67,6 +67,15 @@
<ClCompile Include="win32.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="logger.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="streamlogger.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="sysloglogger.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="application.h">
@ -138,6 +147,15 @@
<ClInclude Include="variant.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="logger.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="streamlogger.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="sysloglogger.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Headerdateien">

View File

@ -7,7 +7,7 @@ namespace icinga
/**
* A logger that logs to stdout.
*/
class StreamLogger : public Logger
class I2_BASE_API StreamLogger : public Logger
{
public:
typedef shared_ptr<StreamLogger> Ptr;

View File

@ -1,3 +1,4 @@
#ifndef _WIN32
#include "i2-base.h"
using namespace icinga;
@ -40,3 +41,4 @@ void SyslogLogger::ProcessLogEntry(const LogEntry& entry)
syslog(severity | LOG_USER, "%s", entry.Message.c_str());
}
#endif /* _WIN32 */

View File

@ -1,13 +1,14 @@
#ifndef SYSLOGLOGGER_H
#define SYSLOGLOGGER_H
#ifndef _WIN32
namespace icinga
{
/**
* A logger that logs to syslog.
*/
class SyslogLogger : public Logger
class I2_BASE_API SyslogLogger : public Logger
{
public:
typedef shared_ptr<SyslogLogger> Ptr;
@ -20,5 +21,6 @@ protected:
};
}
#endif /* _WIN32 */
#endif /* SYSLOGLOGGER_H */

View File

@ -103,8 +103,12 @@ int IcingaApplication::Main(const vector<string>& args)
throw invalid_argument("No config file was specified on the command line.");
if (enableSyslog) {
#ifndef _WIN32
SyslogLogger::Ptr syslogLogger = boost::make_shared<SyslogLogger>(LogInformation);
Logger::RegisterLogger(syslogLogger);
#else /* _WIN32 */
throw invalid_argument("Syslog is not supported on Windows.");
#endif /* _WIN32 */
}
string componentDirectory = Utility::DirName(GetExePath()) + "/../lib/icinga2";