Add syslog support.
This commit is contained in:
parent
e97cd98f90
commit
faf793b0aa
5 changed files with 36 additions and 8 deletions
11
src/App.cpp
11
src/App.cpp
|
@ -40,6 +40,11 @@
|
|||
#include "workers/Workers.h"
|
||||
|
||||
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
# include "log/SysLog.h"
|
||||
#endif
|
||||
|
||||
|
||||
App *App::m_self = nullptr;
|
||||
|
||||
|
||||
|
@ -63,6 +68,12 @@ App::App(int argc, char **argv) :
|
|||
Log::add(new FileLog(m_options->logFile()));
|
||||
}
|
||||
|
||||
# ifdef HAVE_SYSLOG_H
|
||||
if (m_options->syslog()) {
|
||||
Log::add(new SysLog());
|
||||
}
|
||||
# endif
|
||||
|
||||
m_network = new Network(m_options);
|
||||
|
||||
uv_signal_init(uv_default_loop(), &m_signal);
|
||||
|
|
|
@ -22,19 +22,26 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
|
||||
#include "log/SysLog.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
SysLog::SysLog()
|
||||
{
|
||||
openlog(APP_ID, LOG_PID, LOG_USER);
|
||||
}
|
||||
|
||||
|
||||
void SysLog::message(int level, const char* fmt, va_list args)
|
||||
void SysLog::message(int level, const char *fmt, va_list args)
|
||||
{
|
||||
vsyslog(level, fmt, args);
|
||||
}
|
||||
|
||||
|
||||
void SysLog::text(const char* fmt, va_list args)
|
||||
void SysLog::text(const char *fmt, va_list args)
|
||||
{
|
||||
message(LOG_INFO, fmt, args);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SYSLOG_BACKEND_H__
|
||||
#define __SYSLOG_BACKEND_H__
|
||||
#ifndef __SYSLOG_H__
|
||||
#define __SYSLOG_H__
|
||||
|
||||
|
||||
#include "interfaces/ILogBackend.h"
|
||||
|
@ -33,8 +33,8 @@ class SysLog : public ILogBackend
|
|||
public:
|
||||
SysLog();
|
||||
|
||||
void message(int level, const char* fmt, va_list args) override;
|
||||
void text(const char* fmt, va_list args) override;
|
||||
void message(int level, const char *fmt, va_list args) override;
|
||||
void text(const char *fmt, va_list args) override;
|
||||
};
|
||||
|
||||
#endif /* __SYSLOG_BACKEND_H__ */
|
||||
|
|
|
@ -152,7 +152,7 @@ void Hashrate::print()
|
|||
char num3[8];
|
||||
char num4[8];
|
||||
|
||||
LOG_INFO(Options::i()->colors() ? "\x1B[01;37mspeed\x1B[0m 2.5s/60s/15m \x1B[01;36m%s \x1B[22;36m%s %s \x1B[01;36mH/s\x1B[0m max: \x1B[01;36m%s H/s" : "speed 2.5s/60s/15m %s %s %s H/s highest: %s H/s",
|
||||
LOG_INFO(Options::i()->colors() ? "\x1B[01;37mspeed\x1B[0m 2.5s/60s/15m \x1B[01;36m%s \x1B[22;36m%s %s \x1B[01;36mH/s\x1B[0m max: \x1B[01;36m%s H/s" : "speed 2.5s/60s/15m %s %s %s H/s max: %s H/s",
|
||||
format(calc(2500), num1, sizeof(num1)),
|
||||
format(calc(60000), num2, sizeof(num2)),
|
||||
format(calc(900000), num3, sizeof(num3)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue