feisty meow concerns codebase  2.140
console_logger.h
Go to the documentation of this file.
1 #ifndef CONSOLE_LOGGER_CLASS
2 #define CONSOLE_LOGGER_CLASS
3 
4 /*****************************************************************************\
5 * *
6 * Name : console_logger *
7 * Author : Chris Koeritz *
8 * *
9 *******************************************************************************
10 * Copyright (c) 2000-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
17 
19 
24 #include "standard_log_base.h"
25 
26 #include <basis/astring.h>
27 #include <basis/contracts.h>
28 #include <basis/enhance_cpp.h>
29 
30 namespace loggers {
31 
32 class console_logger : public virtual standard_log_base
33 {
34 public:
36 
39 
40  virtual ~console_logger();
41 
42  DEFINE_CLASS_NAME("console_logger");
43 
44  bool to_standard_output() const { return c_target == TO_STDOUT; }
46 
47  bool to_standard_error() const { return c_target == TO_STDERR; }
49 
50  void set_output(stream_choices target) { c_target = target; }
52 
53  virtual basis::outcome log(const basis::base_string &info, int filter);
55 
62 private:
63  stream_choices c_target;
64 };
65 
67 
69 #define SETUP_CONSOLE_LOGGER { \
70  loggers::standard_log_base *old_log = loggers::program_wide_logger::set \
71  (new loggers::console_logger); \
72  /* assumes we are good to entirely remove the old logger. */ \
73  WHACK(old_log); \
74 }
75 
76 } // namespace.
77 
78 #endif
79 
Defines the base class for all string processing objects in hoople.
Definition: base_string.h:28
Outcomes describe the state of completion for an operation.
Definition: outcome.h:31
bool to_standard_output() const
reports if the logger goes to standard output (default).
virtual basis::outcome log(const basis::base_string &info, int filter)
sends the string "info" to the standard output device.
bool to_standard_error() const
reports if the logger goes to standard error instead.
console_logger(stream_choices log_target=TO_STDOUT)
if "standard_error" is true, than stderr is used instead of stdout.
DEFINE_CLASS_NAME("console_logger")
void set_output(stream_choices target)
enables the target of logging to be changed after construction.
A base class for a very usable logger with a filter_set and eol awareness.
A logger that sends to the console screen using the standard output device.