* scribo/debug/logger.hh: Here.
---
scribo/ChangeLog | 6 ++++++
scribo/scribo/debug/logger.hh | 34 ++++++++++++++++++++++++++++++++--
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index b965146..cc3608f 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,11 @@
2012-05-11 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add a default verbose mode in debug::logger.
+
+ * scribo/debug/logger.hh: Here.
+
+2012-05-11 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Make use of logger features.
* scribo/binarization/internal/local_threshold_core.hh,
diff --git a/scribo/scribo/debug/logger.hh b/scribo/scribo/debug/logger.hh
index 5822cf3..cac2770 100644
--- a/scribo/scribo/debug/logger.hh
+++ b/scribo/scribo/debug/logger.hh
@@ -101,6 +101,13 @@ namespace scribo
bool is_verbose() const;
bool is_at_verbose_mode(VerboseMode mode) const;
+ /// The default verbose mode used while logging with
+ /// #operator<<.
+ bool set_default_verbose_mode(VerboseMode mode);
+ VerboseMode default_verbose_mode() const;
+
+ /// Set the current verbose mode, filtering the debug output
+ /// logged through this object.
bool set_verbose_mode(VerboseMode mode);
VerboseMode verbose_mode() const;
@@ -194,6 +201,7 @@ namespace scribo
Level level_;
VerboseMode verbose_mode_;
+ VerboseMode default_verbose_mode_;
std::string verbose_prefix_;
std::ostream& stream_;
@@ -234,6 +242,7 @@ namespace scribo
logger_::logger_()
: level_(None),
verbose_mode_(Mute),
+ default_verbose_mode_(Low),
stream_(std::cerr),
verbose_prefix_("LOG: ")
{
@@ -267,6 +276,27 @@ namespace scribo
inline
bool
+ logger_::set_default_verbose_mode(VerboseMode mode)
+ {
+ if (mode != Invalid)
+ {
+ default_verbose_mode_ = mode;
+ return true;
+ }
+ return false;
+ }
+
+
+ inline
+ VerboseMode
+ logger_::default_verbose_mode() const
+ {
+ return default_verbose_mode_;
+ }
+
+
+ inline
+ bool
logger_::set_verbose_mode(VerboseMode mode)
{
if (mode != Invalid)
@@ -475,7 +505,7 @@ namespace scribo
logger_&
logger_::operator<<(const V& v)
{
- if (verbose_mode_ >= Low)
+ if (verbose_mode_ >= default_verbose_mode_)
stream_ << v;
return *this;
}
@@ -484,7 +514,7 @@ namespace scribo
logger_&
logger_::operator<<(std::ostream& (*f)(std::ostream&))
{
- if (verbose_mode_ >= Low)
+ if (verbose_mode_ >= default_verbose_mode_)
f(stream_);
return *this;
}
--
1.7.2.5
Show replies by date