#pragma once #include #include #ifdef H804_SYSTEMD_ENABLE #include #endif namespace h804 { enum class LogLevel : size_t { DEBUG, INFO, NOTICE, WARN, ERROR, _SIZE }; void daemon_notify_ready(); void daemon_notify(const std::string& args); void _log(const LogLevel, const std::string&); void _log(const LogLevel, const char*); class _Logger { LogLevel level; public: _Logger(LogLevel level); void operator<<(const std::string&) const; void operator<<(const char*) const; }; const _Logger debug(LogLevel::DEBUG); const _Logger info(LogLevel::INFO); const _Logger notice(LogLevel::NOTICE); const _Logger warn(LogLevel::WARN); const _Logger error(LogLevel::ERROR); class errno_exception : public std::exception { const std::string _what; public: const int saved_errno; errno_exception() noexcept; errno_exception(const char* msg) noexcept; const char* what() const noexcept; }; void check(long x); void check(long x, const char* msg); } // namespace h804