Merge pull request #182 from godbyk/fix-missing-includes

Fixed header include problems.
This commit is contained in:
Gabi Melman 2016-02-26 01:14:48 +02:00
commit c6f8f1d272
29 changed files with 418 additions and 304 deletions

View File

@ -84,7 +84,7 @@ install:
- sed -i 's/march=native/msse4.2/' example/Makefile - sed -i 's/march=native/msse4.2/' example/Makefile
- if [ ! -d build ]; then mkdir build; fi - if [ ! -d build ]; then mkdir build; fi
- export CXX_FLAGS="" - export CXX_FLAGS="-I${CHECKOUT_PATH}/include"
- export CXX_LINKER_FLAGS="" - export CXX_LINKER_FLAGS=""
- if [ -z "$BUILD_TYPE" ]; then export BUILD_TYPE=Release; fi - if [ -z "$BUILD_TYPE" ]; then export BUILD_TYPE=Release; fi
- if [ "$ASAN" == "On"]; then export CXX_FLAGS="${CXX_FLAGS} -fsanitize=address,undefined,integer -fno-omit-frame-pointer -fno-sanitize=unsigned-integer-overflow"; fi - if [ "$ASAN" == "On"]; then export CXX_FLAGS="${CXX_FLAGS} -fsanitize=address,undefined,integer -fno-omit-frame-pointer -fno-sanitize=unsigned-integer-overflow"; fi

View File

@ -15,12 +15,13 @@
// 3. will throw spdlog_ex upon log exceptions // 3. will throw spdlog_ex upon log exceptions
// Upong destruction, logs all remaining messages in the queue before destructing.. // Upong destruction, logs all remaining messages in the queue before destructing..
#include <spdlog/common.h>
#include <spdlog/logger.h>
#include <chrono> #include <chrono>
#include <functional> #include <functional>
#include "common.h" #include <string>
#include "logger.h" #include <memory>
#include "spdlog.h"
namespace spdlog namespace spdlog
{ {
@ -69,4 +70,5 @@ private:
} }
#include "./details/async_logger_impl.h" #include <spdlog/details/async_logger_impl.h>

View File

@ -9,6 +9,7 @@
#include <initializer_list> #include <initializer_list>
#include <chrono> #include <chrono>
#include <memory> #include <memory>
#include <exception>
//visual studio does not support noexcept yet //visual studio does not support noexcept yet
#ifndef _MSC_VER #ifndef _MSC_VER
@ -94,4 +95,4 @@ private:
}; };
} //spdlog } //spdlog

View File

@ -14,17 +14,22 @@
#pragma once #pragma once
#include <spdlog/common.h>
#include <spdlog/sinks/sink.h>
#include <spdlog/details/mpmc_bounded_q.h>
#include <spdlog/details/log_msg.h>
#include <spdlog/details/format.h>
#include <spdlog/details/os.h>
#include <spdlog/formatter.h>
#include <chrono> #include <chrono>
#include <thread> #include <exception>
#include <functional> #include <functional>
#include <memory>
#include "../common.h" #include <string>
#include "../sinks/sink.h" #include <thread>
#include "./mpmc_bounded_q.h" #include <utility>
#include "./log_msg.h" #include <vector>
#include "./format.h"
#include "./os.h"
namespace spdlog namespace spdlog
{ {

View File

@ -8,8 +8,13 @@
// Async Logger implementation // Async Logger implementation
// Use an async_sink (queue per logger) to perform the logging in a worker thread // Use an async_sink (queue per logger) to perform the logging in a worker thread
#include "./async_log_helper.h" #include <spdlog/details/async_log_helper.h>
#include <spdlog/async_logger.h>
#include <string>
#include <functional>
#include <chrono>
#include <memory>
template<class It> template<class It>
inline spdlog::async_logger::async_logger(const std::string& logger_name, inline spdlog::async_logger::async_logger(const std::string& logger_name,

View File

@ -10,13 +10,13 @@
// Can be set to auto flush on every line // Can be set to auto flush on every line
// Throw spdlog_ex exception on errors // Throw spdlog_ex exception on errors
#include <spdlog/details/os.h>
#include <spdlog/details/log_msg.h>
#include <chrono>
#include <cstdio>
#include <string> #include <string>
#include <thread> #include <thread>
#include <chrono>
#include "os.h"
#include "log_msg.h"
namespace spdlog namespace spdlog
{ {

View File

@ -1,201 +0,0 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include <type_traits>
#include "../common.h"
#include "../logger.h"
// Line logger class - aggregates operator<< calls to fast ostream
// and logs upon destruction
namespace spdlog
{
namespace details
{
class line_logger
{
public:
line_logger(logger* callback_logger, level::level_enum msg_level, bool enabled):
_callback_logger(callback_logger),
_log_msg(msg_level),
_enabled(enabled)
{}
// No copy intended. Only move
line_logger(const line_logger& other) = delete;
line_logger& operator=(const line_logger&) = delete;
line_logger& operator=(line_logger&&) = delete;
line_logger(line_logger&& other) :
_callback_logger(other._callback_logger),
_log_msg(std::move(other._log_msg)),
_enabled(other._enabled)
{
other.disable();
}
//Log the log message using the callback logger
~line_logger()
{
if (_enabled)
{
#ifndef SPDLOG_NO_NAME
_log_msg.logger_name = _callback_logger->name();
#endif
#ifndef SPDLOG_NO_DATETIME
_log_msg.time = os::now();
#endif
#ifndef SPDLOG_NO_THREAD_ID
_log_msg.thread_id = os::thread_id();
#endif
_callback_logger->_log_msg(_log_msg);
}
}
//
// Support for format string with variadic args
//
void write(const char* what)
{
if (_enabled)
_log_msg.raw << what;
}
template <typename... Args>
void write(const char* fmt, const Args&... args)
{
if (!_enabled)
return;
try
{
_log_msg.raw.write(fmt, args...);
}
catch (const fmt::FormatError& e)
{
throw spdlog_ex(fmt::format("formatting error while processing format string '{}': {}", fmt, e.what()));
}
}
//
// Support for operator<<
//
line_logger& operator<<(const char* what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
line_logger& operator<<(const std::string& what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
line_logger& operator<<(int what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
line_logger& operator<<(unsigned int what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
line_logger& operator<<(long what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
line_logger& operator<<(unsigned long what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
line_logger& operator<<(long long what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
line_logger& operator<<(unsigned long long what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
line_logger& operator<<(double what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
line_logger& operator<<(long double what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
line_logger& operator<<(float what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
line_logger& operator<<(char what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
//Support user types which implements operator<<
template<typename T>
line_logger& operator<<(const T& what)
{
if (_enabled)
_log_msg.raw.write("{}", what);
return *this;
}
void disable()
{
_enabled = false;
}
bool is_enabled() const
{
return _enabled;
}
private:
logger* _callback_logger;
log_msg _log_msg;
bool _enabled;
};
} //Namespace details
} // Namespace spdlog

View File

@ -0,0 +1,78 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include <spdlog/common.h>
#include <spdlog/details/log_msg.h>
#include <string>
// Line logger class - aggregates operator<< calls to fast ostream
// and logs upon destruction
namespace spdlog
{
// Forward declaration
class logger;
namespace details
{
class line_logger
{
public:
line_logger(logger* callback_logger, level::level_enum msg_level, bool enabled);
// No copy intended. Only move
line_logger(const line_logger& other) = delete;
line_logger& operator=(const line_logger&) = delete;
line_logger& operator=(line_logger&&) = delete;
line_logger(line_logger&& other);
//Log the log message using the callback logger
~line_logger();
//
// Support for format string with variadic args
//
void write(const char* what);
template <typename... Args>
void write(const char* fmt, const Args&... args);
//
// Support for operator<<
//
line_logger& operator<<(const char* what);
line_logger& operator<<(const std::string& what);
line_logger& operator<<(int what);
line_logger& operator<<(unsigned int what);
line_logger& operator<<(long what);
line_logger& operator<<(unsigned long what);
line_logger& operator<<(long long what);
line_logger& operator<<(unsigned long long what);
line_logger& operator<<(double what);
line_logger& operator<<(long double what);
line_logger& operator<<(float what);
line_logger& operator<<(char what);
//Support user types which implements operator<<
template<typename T>
line_logger& operator<<(const T& what);
void disable();
bool is_enabled() const;
private:
logger* _callback_logger;
log_msg _log_msg;
bool _enabled;
};
} //Namespace details
} // Namespace spdlog

View File

@ -0,0 +1,185 @@
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include <type_traits>
#include <spdlog/details/line_logger_fwd.h>
#include <spdlog/common.h>
#include <spdlog/logger.h>
#include <string>
#include <utility>
// Line logger class - aggregates operator<< calls to fast ostream
// and logs upon destruction
inline spdlog::details::line_logger::line_logger(logger* callback_logger, level::level_enum msg_level, bool enabled):
_callback_logger(callback_logger),
_log_msg(msg_level),
_enabled(enabled)
{}
inline spdlog::details::line_logger::line_logger(line_logger&& other) :
_callback_logger(other._callback_logger),
_log_msg(std::move(other._log_msg)),
_enabled(other._enabled)
{
other.disable();
}
//Log the log message using the callback logger
inline spdlog::details::line_logger::~line_logger()
{
if (_enabled)
{
#ifndef SPDLOG_NO_NAME
_log_msg.logger_name = _callback_logger->name();
#endif
#ifndef SPDLOG_NO_DATETIME
_log_msg.time = os::now();
#endif
#ifndef SPDLOG_NO_THREAD_ID
_log_msg.thread_id = os::thread_id();
#endif
_callback_logger->_log_msg(_log_msg);
}
}
//
// Support for format string with variadic args
//
inline void spdlog::details::line_logger::write(const char* what)
{
if (_enabled)
_log_msg.raw << what;
}
template <typename... Args>
inline void spdlog::details::line_logger::write(const char* fmt, const Args&... args)
{
if (!_enabled)
return;
try
{
_log_msg.raw.write(fmt, args...);
}
catch (const fmt::FormatError& e)
{
throw spdlog_ex(fmt::format("formatting error while processing format string '{}': {}", fmt, e.what()));
}
}
//
// Support for operator<<
//
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(const char* what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(const std::string& what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(int what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(unsigned int what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(long what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(unsigned long what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(long long what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(unsigned long long what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(double what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(long double what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(float what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(char what)
{
if (_enabled)
_log_msg.raw << what;
return *this;
}
//Support user types which implements operator<<
template<typename T>
inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(const T& what)
{
if (_enabled)
_log_msg.raw.write("{}", what);
return *this;
}
inline void spdlog::details::line_logger::disable()
{
_enabled = false;
}
inline bool spdlog::details::line_logger::is_enabled() const
{
return _enabled;
}

View File

@ -5,9 +5,11 @@
#pragma once #pragma once
#include <thread> #include <spdlog/common.h>
#include "../common.h" #include <spdlog/details/format.h>
#include "./format.h"
#include <string>
#include <utility>
namespace spdlog namespace spdlog
{ {

View File

@ -5,7 +5,11 @@
#pragma once #pragma once
#include "./line_logger.h" #include <spdlog/logger.h>
#include <atomic>
#include <memory>
#include <string>
// create logger with given name, sinks and the default pattern formatter // create logger with given name, sinks and the default pattern formatter
// all other ctors will call this one // all other ctors will call this one
@ -296,4 +300,4 @@ inline void spdlog::logger::flush()
{ {
for (auto& sink : _sinks) for (auto& sink : _sinks)
sink->flush(); sink->flush();
} }

View File

@ -43,8 +43,10 @@ Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once #pragma once
#include <spdlog/common.h>
#include <atomic> #include <atomic>
#include "../common.h" #include <utility>
namespace spdlog namespace spdlog
{ {

View File

@ -4,9 +4,12 @@
// //
#pragma once #pragma once
#include<string> #include <spdlog/common.h>
#include<cstdio>
#include<ctime> #include <cstdio>
#include <ctime>
#include <functional>
#include <string>
#ifdef _WIN32 #ifdef _WIN32
# ifndef WIN32_LEAN_AND_MEAN # ifndef WIN32_LEAN_AND_MEAN
@ -22,12 +25,11 @@
#include <sys/syscall.h> //Use gettid() syscall under linux to get thread id #include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <chrono>
#else #else
#include <thread> #include <thread>
#endif #endif
#include "../common.h"
namespace spdlog namespace spdlog
{ {
namespace details namespace details

View File

@ -5,16 +5,18 @@
#pragma once #pragma once
#include <string> #include <spdlog/formatter.h>
#include <spdlog/details/log_msg.h>
#include <spdlog/details/os.h>
#include <chrono> #include <chrono>
#include <ctime>
#include <memory> #include <memory>
#include <vector> #include <mutex>
#include <string>
#include <thread> #include <thread>
#include <utility>
#include <vector>
#include "../formatter.h"
#include "./log_msg.h"
#include "./os.h"
namespace spdlog namespace spdlog
{ {

View File

@ -10,15 +10,17 @@
// If user requests a non existing logger, nullptr will be returned // If user requests a non existing logger, nullptr will be returned
// This class is thread safe // This class is thread safe
#include <string> #include <spdlog/details/null_mutex.h>
#include <mutex> #include <spdlog/logger.h>
#include <unordered_map> #include <spdlog/async_logger.h>
#include <functional> #include <spdlog/common.h>
#include "./null_mutex.h" #include <chrono>
#include "../logger.h" #include <functional>
#include "../async_logger.h" #include <memory>
#include "../common.h" #include <mutex>
#include <string>
#include <unordered_map>
namespace spdlog namespace spdlog
{ {

View File

@ -8,10 +8,16 @@
// //
// Global registry functions // Global registry functions
// //
#include "registry.h" #include <spdlog/spdlog.h>
#include "../sinks/file_sinks.h" #include <spdlog/details/registry.h>
#include "../sinks/stdout_sinks.h" #include <spdlog/sinks/file_sinks.h>
#include "../sinks/syslog_sink.h" #include <spdlog/sinks/stdout_sinks.h>
#include <spdlog/sinks/syslog_sink.h>
#include <chrono>
#include <functional>
#include <memory>
#include <string>
inline void spdlog::register_logger(std::shared_ptr<logger> logger) inline void spdlog::register_logger(std::shared_ptr<logger> logger)
{ {

View File

@ -5,7 +5,12 @@
#pragma once #pragma once
#include "details/log_msg.h" #include <spdlog/details/log_msg.h>
#include <vector>
#include <string>
#include <memory>
namespace spdlog namespace spdlog
{ {
namespace details namespace details
@ -36,5 +41,5 @@ private:
}; };
} }
#include "details/pattern_formatter_impl.h" #include <spdlog/details/pattern_formatter_impl.h>

View File

@ -12,19 +12,18 @@
// 2. Format the message using the formatter function // 2. Format the message using the formatter function
// 3. Pass the formatted message to its sinks to performa the actual logging // 3. Pass the formatted message to its sinks to performa the actual logging
#include<vector> #include <spdlog/sinks/base_sink.h>
#include<memory> #include <spdlog/common.h>
#include "sinks/base_sink.h" #include <spdlog/details/line_logger_fwd.h>
#include "common.h"
#include <vector>
#include <memory>
#include <atomic>
#include <string>
namespace spdlog namespace spdlog
{ {
namespace details
{
class line_logger;
}
class logger class logger
{ {
public: public:
@ -110,4 +109,6 @@ protected:
}; };
} }
#include "./details/logger_impl.h" #include <spdlog/details/logger_impl.h>
#include <spdlog/details/line_logger_impl.h>

View File

@ -7,12 +7,14 @@
#if defined(__ANDROID__) #if defined(__ANDROID__)
#include <mutex> #include <spdlog/sinks/base_sink.h>
#include "base_sink.h" #include <spdlog/details/null_mutex.h>
#include "../details/null_mutex.h"
#include <android/log.h> #include <android/log.h>
#include <mutex>
#include <string>
namespace spdlog namespace spdlog
{ {
namespace sinks namespace sinks

View File

@ -10,14 +10,12 @@
// all locking is taken care of here so no locking needed by the implementors.. // all locking is taken care of here so no locking needed by the implementors..
// //
#include<string> #include <spdlog/sinks/sink.h>
#include<mutex> #include <spdlog/formatter.h>
#include<atomic> #include <spdlog/common.h>
#include "./sink.h" #include <spdlog/details/log_msg.h>
#include "../formatter.h"
#include "../common.h"
#include "../details/log_msg.h"
#include <mutex>
namespace spdlog namespace spdlog
{ {

View File

@ -5,15 +5,15 @@
#pragma once #pragma once
#include <spdlog/details/log_msg.h>
#include <spdlog/details/null_mutex.h>
#include <spdlog/sinks/base_sink.h>
#include <spdlog/sinks/sink.h>
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <mutex> #include <mutex>
#include <list> #include <vector>
#include "../details/log_msg.h"
#include "../details/null_mutex.h"
#include "./base_sink.h"
#include "./sink.h"
namespace spdlog namespace spdlog
{ {

View File

@ -5,11 +5,17 @@
#pragma once #pragma once
#include <spdlog/sinks/base_sink.h>
#include <spdlog/details/null_mutex.h>
#include <spdlog/details/file_helper.h>
#include <spdlog/details/format.h>
#include <algorithm>
#include <chrono>
#include <cstdio>
#include <ctime>
#include <mutex> #include <mutex>
#include "base_sink.h" #include <string>
#include "../details/null_mutex.h"
#include "../details/file_helper.h"
#include "../details/format.h"
namespace spdlog namespace spdlog
{ {

View File

@ -4,10 +4,11 @@
// //
#pragma once #pragma once
#include <mutex>
#include "./base_sink.h"
#include "../details/null_mutex.h"
#include <spdlog/sinks/base_sink.h>
#include <spdlog/details/null_mutex.h>
#include <mutex>
namespace spdlog namespace spdlog
{ {

View File

@ -5,12 +5,11 @@
#pragma once #pragma once
#include <spdlog/details/null_mutex.h>
#include <spdlog/sinks/base_sink.h>
#include <ostream> #include <ostream>
#include <mutex> #include <mutex>
#include <memory>
#include "../details/null_mutex.h"
#include "./base_sink.h"
namespace spdlog namespace spdlog
{ {

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include "../details/log_msg.h" #include <spdlog/details/log_msg.h>
namespace spdlog namespace spdlog
{ {

View File

@ -5,10 +5,12 @@
#pragma once #pragma once
#include <spdlog/sinks/ostream_sink.h>
#include <spdlog/details/null_mutex.h>
#include <iostream> #include <iostream>
#include <memory>
#include <mutex> #include <mutex>
#include "./ostream_sink.h"
#include "../details/null_mutex.h"
namespace spdlog namespace spdlog
{ {

View File

@ -7,14 +7,14 @@
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
#include <spdlog/sinks/sink.h>
#include <spdlog/common.h>
#include <spdlog/details/log_msg.h>
#include <array> #include <array>
#include <string> #include <string>
#include <syslog.h> #include <syslog.h>
#include "./sink.h"
#include "../common.h"
#include "../details/log_msg.h"
namespace spdlog namespace spdlog
{ {

View File

@ -8,9 +8,14 @@
#pragma once #pragma once
#include "tweakme.h" #include <spdlog/tweakme.h>
#include "common.h" #include <spdlog/common.h>
#include "logger.h" #include <spdlog/logger.h>
#include <memory>
#include <functional>
#include <chrono>
#include <string>
namespace spdlog namespace spdlog
{ {
@ -132,4 +137,4 @@ void drop_all();
} }
#include "details/spdlog_impl.h" #include <spdlog/details/spdlog_impl.h>

View File

@ -1,5 +1,5 @@
CXX ?= g++ CXX ?= g++
CXXFLAGS = -Wall -pedantic -std=c++11 -pthread -O2 CXXFLAGS = -Wall -pedantic -std=c++11 -pthread -O2 -I../include
LDPFALGS = -pthread LDPFALGS = -pthread
CPP_FILES := $(wildcard *.cpp) CPP_FILES := $(wildcard *.cpp)