[med-svn] [spdlog] 01/01: New upstream version 1.12
Michael Crusoe
misterc-guest at moszumanska.debian.org
Sun Sep 18 12:54:20 UTC 2016
This is an automated email from the git hooks/post-receive script.
misterc-guest pushed a commit to annotated tag upstream/1.12
in repository spdlog.
commit 4bcdabfb8091b57ab9943d04477dc21c85a86651
Author: Michael R. Crusoe <michael.crusoe at gmail.com>
Date: Sun Sep 18 05:42:11 2016 -0700
New upstream version 1.12
---
README.md | 21 +++++++--------------
include/spdlog/details/pattern_formatter_impl.h | 16 ++++++++++++----
include/spdlog/details/spdlog_impl.h | 8 ++++----
include/spdlog/sinks/file_sinks.h | 5 +++--
include/spdlog/spdlog.h | 4 ++--
5 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/README.md b/README.md
index 2c77cc7..435ce5d 100644
--- a/README.md
+++ b/README.md
@@ -14,8 +14,7 @@ Just copy the source [folder](https://github.com/gabime/spdlog/tree/master/inclu
##Features
* Very fast - performance is the primary goal (see [benchmarks](#benchmarks) below).
-* Headers only.
-* No dependencies - just copy and use.
+* Headers only, just copy and use.
* Feature rich [call style](#usage-example) using the excellent [fmt](https://github.com/fmtlib/fmt) library.
* Extremely fast asynchronous mode (optional) - using lockfree queues and other tricks to reach millions of calls/sec.
* [Custom](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) formatting.
@@ -24,7 +23,7 @@ Just copy the source [folder](https://github.com/gabime/spdlog/tree/master/inclu
* Rotating log files.
* Daily log files.
* Console logging (colors supported).
- * Linux syslog.
+ * syslog.
* Easily extendable with custom log targets (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface).
* Severity based filtering - threshold levels can be modified in runtime as well as in compile time.
@@ -58,13 +57,7 @@ Time needed to log 1,000,000 lines in asynchronous mode, i.e. the time it takes
## Usage Example
```c++
-//
-// Copyright(c) 2015 Gabi Melman.
-// Distributed under the MIT License (http://opensource.org/licenses/MIT)
-//
-//
-// spdlog usage example
-//
+
#include "spdlog/spdlog.h"
#include <iostream>
@@ -83,7 +76,7 @@ int main(int, char*[])
// Multithreaded color console
auto console = spd::stdout_logger_mt("console", true);
console->info("Welcome to spdlog!");
- console->error("An info message example {}..", 1);
+ console->info("An info message example {}..", 1);
// Formatting examples
console->warn("Easy padding in numbers like {:08d}", 12);
@@ -162,13 +155,13 @@ void async_example()
async_file->info("Async message #{}", i);
}
-//syslog example (linux/osx only)
+//syslog example
void syslog_example()
{
-#if defined (__linux__) || defined(__APPLE__)
+#ifdef SPDLOG_ENABLE_SYSLOG
std::string ident = "spdlog-example";
auto syslog_logger = spd::syslog_logger("syslog", ident, LOG_PID);
- syslog_logger->warn("This is warning that will end up in syslog. This is Linux only!");
+ syslog_logger->warn("This is warning that will end up in syslog..");
#endif
}
diff --git a/include/spdlog/details/pattern_formatter_impl.h b/include/spdlog/details/pattern_formatter_impl.h
index 663a255..73c0db3 100644
--- a/include/spdlog/details/pattern_formatter_impl.h
+++ b/include/spdlog/details/pattern_formatter_impl.h
@@ -319,13 +319,21 @@ public:
// it is very fast (already stored in tm.tm_gmtoff)
int total_minutes = os::utc_minutes_offset(tm_time);
#endif
+ bool is_negative = total_minutes < 0;
+ char sign;
+ if (is_negative)
+ {
+ total_minutes = -total_minutes;
+ sign = '-';
+ }
+ else
+ {
+ sign = '+';
+ }
int h = total_minutes / 60;
int m = total_minutes % 60;
- if (h >= 0) //minus sign will be printed anyway if negative
- {
- msg.formatted << '+';
- }
+ msg.formatted << sign;
pad_n_join(msg.formatted, h, m, ':');
}
private:
diff --git a/include/spdlog/details/spdlog_impl.h b/include/spdlog/details/spdlog_impl.h
index 4ef085b..fb4e6f8 100644
--- a/include/spdlog/details/spdlog_impl.h
+++ b/include/spdlog/details/spdlog_impl.h
@@ -36,14 +36,14 @@ inline void spdlog::drop(const std::string &name)
}
// Create multi/single threaded simple file logger
-inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_mt(const std::string& logger_name, const filename_t& filename, bool force_flush)
+inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_mt(const std::string& logger_name, const filename_t& filename, bool force_flush, bool truncate)
{
- return create<spdlog::sinks::simple_file_sink_mt>(logger_name, filename, force_flush);
+ return create<spdlog::sinks::simple_file_sink_mt>(logger_name, filename, force_flush, truncate);
}
-inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_st(const std::string& logger_name, const filename_t& filename, bool force_flush)
+inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_st(const std::string& logger_name, const filename_t& filename, bool force_flush, bool truncate)
{
- return create<spdlog::sinks::simple_file_sink_st>(logger_name, filename, force_flush);
+ return create<spdlog::sinks::simple_file_sink_st>(logger_name, filename, force_flush, truncate);
}
// Create multi/single threaded rotating file logger
diff --git a/include/spdlog/sinks/file_sinks.h b/include/spdlog/sinks/file_sinks.h
index a687f99..ff76759 100644
--- a/include/spdlog/sinks/file_sinks.h
+++ b/include/spdlog/sinks/file_sinks.h
@@ -30,10 +30,11 @@ class simple_file_sink : public base_sink < Mutex >
{
public:
explicit simple_file_sink(const filename_t &filename,
- bool force_flush = false) :
+ bool force_flush = false,
+ bool truncate = false) :
_file_helper(force_flush)
{
- _file_helper.open(filename);
+ _file_helper.open(filename, truncate);
}
void flush() override
{
diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h
index ff1b602..e2b8ba4 100644
--- a/include/spdlog/spdlog.h
+++ b/include/spdlog/spdlog.h
@@ -71,8 +71,8 @@ void set_sync_mode();
//
// Create and register multi/single basic file logger
//
-std::shared_ptr<logger> basic_logger_mt(const std::string& logger_name, const filename_t& filename,bool force_flush = false);
-std::shared_ptr<logger> basic_logger_st(const std::string& logger_name, const filename_t& filename, bool force_flush = false);
+std::shared_ptr<logger> basic_logger_mt(const std::string& logger_name, const filename_t& filename,bool force_flush = false, bool truncate = false);
+std::shared_ptr<logger> basic_logger_st(const std::string& logger_name, const filename_t& filename, bool force_flush = false, bool truncate = false);
//
// Create and register multi/single threaded rotating file logger
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/spdlog.git
More information about the debian-med-commit
mailing list