astyle
This commit is contained in:
		@@ -100,17 +100,21 @@ enum class async_overflow_policy
 | 
				
			|||||||
//
 | 
					//
 | 
				
			||||||
// Log exception
 | 
					// Log exception
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
namespace details { namespace os {
 | 
					namespace details
 | 
				
			||||||
	std::string errno_str(int err_num);	
 | 
					{
 | 
				
			||||||
}}
 | 
					namespace os
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					std::string errno_str(int err_num);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
class spdlog_ex : public std::exception
 | 
					class spdlog_ex : public std::exception
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    spdlog_ex(const std::string& msg) :_msg(msg) {}
 | 
					    spdlog_ex(const std::string& msg) :_msg(msg) {}
 | 
				
			||||||
	spdlog_ex(const std::string& msg, int last_errno)
 | 
					    spdlog_ex(const std::string& msg, int last_errno)
 | 
				
			||||||
	{
 | 
					    {
 | 
				
			||||||
		_msg = msg + ": " + details::os::errno_str(last_errno);
 | 
					        _msg = msg + ": " + details::os::errno_str(last_errno);
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
    const char* what() const SPDLOG_NOEXCEPT override
 | 
					    const char* what() const SPDLOG_NOEXCEPT override
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return _msg.c_str();
 | 
					        return _msg.c_str();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,6 +72,6 @@ inline void spdlog::async_logger::_set_pattern(const std::string& pattern)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
 | 
					inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
 | 
				
			||||||
{    
 | 
					{
 | 
				
			||||||
    _async_log_helper->log(msg);
 | 
					    _async_log_helper->log(msg);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -65,7 +65,7 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* fmt, const Ar
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        throw spdlog::spdlog_ex(std::string("format error in \"") + fmt + "\": " + ex.what());
 | 
					        throw spdlog::spdlog_ex(std::string("format error in \"") + fmt + "\": " + ex.what());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    _sink_it(log_msg);
 | 
					    _sink_it(log_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -87,7 +87,7 @@ inline void spdlog::logger::log(level::level_enum lvl, const T& msg)
 | 
				
			|||||||
    if (!should_log(lvl)) return;
 | 
					    if (!should_log(lvl)) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    details::log_msg log_msg(&_name, lvl);
 | 
					    details::log_msg log_msg(&_name, lvl);
 | 
				
			||||||
    log_msg.raw << msg;    
 | 
					    log_msg.raw << msg;
 | 
				
			||||||
    _sink_it(log_msg);
 | 
					    _sink_it(log_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -254,25 +254,25 @@ inline std::string filename_to_str(const filename_t& filename)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Return errno string (thread safe)
 | 
					// Return errno string (thread safe)
 | 
				
			||||||
inline std::string errno_str(int err_num)
 | 
					inline std::string errno_str(int err_num)
 | 
				
			||||||
{	
 | 
					{
 | 
				
			||||||
	char buf[256];	
 | 
					    char buf[256];
 | 
				
			||||||
	constexpr auto buf_size = sizeof(buf);
 | 
					    constexpr auto buf_size = sizeof(buf);
 | 
				
			||||||
			
 | 
					 | 
				
			||||||
#ifdef _WIN32		
 | 
					 | 
				
			||||||
	if(strerror_s(buf, buf_size, err_num) == 0)
 | 
					 | 
				
			||||||
		return std::string(buf);
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		return "Unkown error";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#elif (_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE // posix version		
 | 
					#ifdef _WIN32
 | 
				
			||||||
	if (strerror_r(err_num, buf, buf_size) == 0)
 | 
					    if(strerror_s(buf, buf_size, err_num) == 0)
 | 
				
			||||||
		return std::string(buf);
 | 
					        return std::string(buf);
 | 
				
			||||||
	else
 | 
					    else
 | 
				
			||||||
		return "Unkown error";
 | 
					        return "Unkown error";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#elif (_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE // posix version        
 | 
				
			||||||
 | 
					    if (strerror_r(err_num, buf, buf_size) == 0)
 | 
				
			||||||
 | 
					        return std::string(buf);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        return "Unkown error";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else  // gnu version (might not use the given buf, so its retval pointer must be used)
 | 
					#else  // gnu version (might not use the given buf, so its retval pointer must be used)
 | 
				
			||||||
	return std::string(strerror_r(err_num, buf, buf_size));
 | 
					    return std::string(strerror_r(err_num, buf, buf_size));
 | 
				
			||||||
#endif		
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} //os
 | 
					} //os
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -130,7 +130,7 @@ void drop_all();
 | 
				
			|||||||
// SPDLOG_TRACE(..) will also print current file and line.
 | 
					// SPDLOG_TRACE(..) will also print current file and line.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Example:
 | 
					// Example:
 | 
				
			||||||
// spdlog::set_level(spdlog::level::trace); 
 | 
					// spdlog::set_level(spdlog::level::trace);
 | 
				
			||||||
// SPDLOG_TRACE(my_logger, "some trace message");
 | 
					// SPDLOG_TRACE(my_logger, "some trace message");
 | 
				
			||||||
// SPDLOG_TRACE(my_logger, "another trace message {} {}", 1, 2);
 | 
					// SPDLOG_TRACE(my_logger, "another trace message {} {}", 1, 2);
 | 
				
			||||||
// SPDLOG_DEBUG(my_logger, "some debug message {} {}", 3, 4);
 | 
					// SPDLOG_DEBUG(my_logger, "some debug message {} {}", 3, 4);
 | 
				
			||||||
@@ -138,7 +138,7 @@ void drop_all();
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef SPDLOG_TRACE_ON
 | 
					#ifdef SPDLOG_TRACE_ON
 | 
				
			||||||
#define SPDLOG_STR_H(x) #x
 | 
					#define SPDLOG_STR_H(x) #x
 | 
				
			||||||
#define SPDLOG_STR_HELPER(x) SPDLOG_STR_H(x) 
 | 
					#define SPDLOG_STR_HELPER(x) SPDLOG_STR_H(x)
 | 
				
			||||||
#define SPDLOG_TRACE(logger, ...) logger->trace("[" __FILE__ " line #" SPDLOG_STR_HELPER(__LINE__) "] " __VA_ARGS__)
 | 
					#define SPDLOG_TRACE(logger, ...) logger->trace("[" __FILE__ " line #" SPDLOG_STR_HELPER(__LINE__) "] " __VA_ARGS__)
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#define SPDLOG_TRACE(logger, ...)
 | 
					#define SPDLOG_TRACE(logger, ...)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user