feisty meow concerns codebase  2.140
combo_logger.h
Go to the documentation of this file.
1 #ifndef COMBO_LOGGER_CLASS
2 #define COMBO_LOGGER_CLASS
3 
4 /*****************************************************************************\
5 * *
6 * Name : combo_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 
18 #include "file_logger.h"
19 
20 namespace loggers {
21 
23 
26 class combo_logger : public virtual file_logger, public virtual console_logger
27 {
28 public:
29  combo_logger(const basis::astring &filename,
31  stream_choices log_target = TO_STDOUT);
32 
33  virtual ~combo_logger() {}
34 
35  DEFINE_CLASS_NAME("combo_logger");
36 
37  virtual basis::outcome log(const basis::base_string &info, int filter = basis::ALWAYS_PRINT);
38 
39  // overrides that enforce properties for both loggers.
40  virtual void add_filter(int new_filter);
41  virtual void remove_filter(int old_filter);
42  virtual void clear_filters();
43  virtual void eol(textual::parser_bits::line_ending to_set);
44 };
45 
47 
49 #define SETUP_COMBO_LOGGER { \
50  basis::base_logger *old_log = program_wide_logger::set \
51  (new loggers::combo_logger \
52  (loggers::file_logger::log_file_for_app_name())); \
53  WHACK(old_log); \
54 }
55 
56 } //namespace.
57 
58 #endif
59 
Provides a dynamically resizable ASCII character string.
Definition: astring.h:35
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
combines a file_logger with a console logger, behaving like the 'tee' command.
Definition: combo_logger.h:27
virtual void add_filter(int new_filter)
Adds a member to the filter set.
combo_logger(const basis::astring &filename, int limit=DEFAULT_LOG_FILE_SIZE, stream_choices log_target=TO_STDOUT)
virtual void remove_filter(int old_filter)
Removes a member from the filter set.
virtual basis::outcome log(const basis::base_string &info, int filter=basis::ALWAYS_PRINT)
sends the string "info" to the standard output device.
virtual void clear_filters()
Resets the filter set to be empty.
DEFINE_CLASS_NAME("combo_logger")
virtual textual::parser_bits::line_ending eol()
observes how line endings are to be printed.
Definition: eol_aware.h:34
@ DEFAULT_LOG_FILE_SIZE
this just defines the default for the log file size.
Definition: file_logger.h:55
int limit() const
observes the allowable size of the log file.
Definition: file_logger.h:87
line_ending
Line endings is an enumeration of the separator character(s) used for text files.
Definition: parser_bits.h:31
A logger that sends to the console screen using the standard output device.