sptk2 logo
SPTK Home Page
SysLogEngine.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#ifndef _WIN32
30
31#include <syslog.h>
32
33#else
34#include <winsock2.h>
35
36#include <windows.h>
37#endif
38
39#include <sptk5/LogEngine.h>
40
41namespace sptk {
42
56class SP_EXPORT SysLogEngine
57 : public LogEngine
58{
59public:
66 void saveMessage(const Logger::UMessage& message) override;
67
80 SysLogEngine(const String& programName, uint32_t facilities = LOG_USER);
81
87 ~SysLogEngine() override;
88
95 void getOptions(uint32_t& options, String& programName, uint32_t& facilities) const;
96
97private:
98#ifdef _WIN32
99 std::atomic<HANDLE> m_logHandle {0};
100 static bool m_registrySet;
101#endif
102
103 static SharedMutex syslogMutex;
104 static std::atomic_bool m_logOpened;
105
106 uint32_t m_facilities;
107 String m_programName;
108
109 void programName(const String& progName);
110
111 void setupEventSource() const;
112};
116} // namespace sptk
Definition: LogEngine.h:60
Definition: String.h:49
Definition: SysLogEngine.h:58
void saveMessage(const Logger::UMessage &message) override
void getOptions(uint32_t &options, String &programName, uint32_t &facilities) const
SysLogEngine(const String &programName, uint32_t facilities=LOG_USER)
~SysLogEngine() override

Fri Oct 14 2022 09:58:32: SPTK 5.4.1