Program Listing for File log.h
↰ Return to documentation for file (include/ur_client_library/log.h
)
/*
* Copyright 2017, 2018 Simon Rasmussen (refactor)
*
* Copyright 2015, 2016 Thomas Timm Andersen (original version)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <inttypes.h>
#include <memory>
#define URCL_LOG_DEBUG(...) urcl::log(__FILE__, __LINE__, urcl::LogLevel::DEBUG, __VA_ARGS__)
#define URCL_LOG_WARN(...) urcl::log(__FILE__, __LINE__, urcl::LogLevel::WARN, __VA_ARGS__)
#define URCL_LOG_INFO(...) urcl::log(__FILE__, __LINE__, urcl::LogLevel::INFO, __VA_ARGS__)
#define URCL_LOG_ERROR(...) urcl::log(__FILE__, __LINE__, urcl::LogLevel::ERROR, __VA_ARGS__)
#define URCL_LOG_FATAL(...) urcl::log(__FILE__, __LINE__, urcl::LogLevel::FATAL, __VA_ARGS__)
namespace urcl
{
enum class LogLevel
{
DEBUG = 0,
INFO,
WARN,
ERROR,
FATAL,
NONE
};
class LogHandler
{
public:
virtual ~LogHandler() = default;
virtual void log(const char* file, int line, LogLevel loglevel, const char* log) = 0;
};
void registerLogHandler(std::unique_ptr<LogHandler> loghandler);
void unregisterLogHandler();
void setLogLevel(LogLevel level);
void log(const char* file, int line, LogLevel level, const char* fmt, ...);
} // namespace urcl