Add Logger Class
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
#include <syslog.h>
|
||||
#include "Logger.h"
|
||||
|
||||
|
||||
namespace PresenceDetection {
|
||||
namespace Util {
|
||||
|
||||
void Logger::Log(Severity::type severity, const std::string& message)
|
||||
{
|
||||
if (severity > Severity::Error)
|
||||
std::cout << message << std::endl;
|
||||
else
|
||||
std::cerr << message << std::endl;
|
||||
|
||||
syslog(static_cast<int>(severity), "%s", message.c_str());
|
||||
}
|
||||
|
||||
} // namespace Util
|
||||
} // namespace PresenceDetection
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef UTIL_LOGGER_H
|
||||
#define UTIL_LOGGER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace PresenceDetection {
|
||||
namespace Util {
|
||||
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
class Severity
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
Emergency = 0,
|
||||
Alert = 1,
|
||||
Critical = 2,
|
||||
Error = 3,
|
||||
Warning = 4,
|
||||
Notice = 5,
|
||||
Info = 6,
|
||||
Debug = 7
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
static void Log(Severity::type severity, const std::string& message);
|
||||
};
|
||||
|
||||
} // namespace Util
|
||||
} // namespace PresenceDetection
|
||||
|
||||
#endif // UTIL_LOGGER_H
|
||||
Reference in New Issue
Block a user