1 #ifndef COMBO_LOGGER_CLASS
2 #define COMBO_LOGGER_CLASS
4 /*****************************************************************************\
7 * Author : Chris Koeritz
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 \*****************************************************************************/
18 #include "file_logger.h"
22 //! combines a file_logger with a console logger, behaving like the 'tee' command.
23 /*! this will output the diagnostic info to both a file and to the console. this is useful
24 when one would like to see the output as its happening but also have a record for later. */
26 class combo_logger : public virtual file_logger, public virtual console_logger
29 combo_logger(const basis::astring &filename,
30 int limit = DEFAULT_LOG_FILE_SIZE,
31 stream_choices log_target = TO_STDOUT);
33 virtual ~combo_logger() {}
35 DEFINE_CLASS_NAME("combo_logger");
37 virtual basis::outcome log(const basis::base_string &info, int filter = basis::ALWAYS_PRINT);
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);
48 //! a macro that retasks the program-wide logger as a combo_logger.
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())); \