23 #include <unordered_map>
27 #include "DebugStream.h"
28 #include "ThreadCreator.h"
29 #include "UTCPSocket.h"
30 #include "CommonEventLoop.h"
31 #include "LogServerTypes.h"
33 #ifndef DISABLE_REST_API
34 #include <Poco/JSON/Object.h>
97 LogServer( std::shared_ptr<DebugStream> log );
98 LogServer( std::shared_ptr<LogAgregator> log );
101 inline void setCmdTimeout( timeout_t msec ) noexcept
106 inline void setSessionLog( Debug::type t ) noexcept
110 inline void setMaxSessionCount(
int num ) noexcept
115 void run(
const std::string& addr, Poco::UInt16 port,
bool thread =
true );
118 inline bool isRunning()
const noexcept
123 bool check(
bool restart_if_fail =
true );
125 void init(
const std::string& prefix, xmlNode* cnode = 0 );
127 static std::string help_print(
const std::string& prefix );
129 std::string getShortInfo();
131 #ifndef DISABLE_REST_API
132 Poco::JSON::Object::Ptr httpGetShortInfo();
138 virtual void evprepare(
const ev::loop_ref& loop )
override;
139 virtual void evfinish(
const ev::loop_ref& loop )
override;
140 virtual std::string wname()
const noexcept
override
145 void ioAccept( ev::io& watcher,
int revents );
147 void saveDefaultLogLevels(
const std::string& logname );
148 void restoreDefaultLogLevels(
const std::string& logname );
149 std::string onCommand(
LogSession* s, LogServerTypes::Command cmd,
const std::string& logname );
154 timeout_t cmdTimeout = { 2000 };
155 Debug::type sessLogLevel = { Debug::NONE };
156 size_t sessMaxCount = { 10 };
158 typedef std::vector< std::shared_ptr<LogSession> > SessionList;
168 std::shared_ptr<UTCPSocket> sock;
169 std::shared_ptr<DebugStream> elog;
175 std::unordered_map< DebugStream*, Debug::type > defaultLogLevels;
177 std::string myname = {
"LogServer" };
178 std::string addr = {
"" };
179 Poco::UInt16 port = { 0 };
181 std::atomic_bool isrunning = {
false };
186 #endif // LogServer_H_