feisty meow concerns codebase  2.140
combo_logger.cpp
Go to the documentation of this file.
1 /*****************************************************************************\
2 * *
3 * Name : combo_logger
4 * Author : Chris Koeritz
5 * *
6 *******************************************************************************
7 * Copyright (c) 2000-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
13 \*****************************************************************************/
14 
15 #include "combo_logger.h"
16 
17 #include <filesystem/directory.h>
18 #include <filesystem/filename.h>
19 #include <mathematics/chaos.h>
21 #include <textual/parser_bits.h>
22 
23 #ifdef __WIN32__
24  #include <io.h>
25 #endif
26 #include <stdio.h>
27 #ifdef __UNIX__
28  #include <unistd.h>
29 #endif
30 
31 using namespace basis;
32 using namespace filesystem;
33 using namespace structures;
34 using namespace textual;
35 
36 namespace loggers {
37 
38 //const int REDUCE_FACTOR = 5;
39  // we whack this portion of the file every time we truncate. if it's set
40  // to 14, for example, then a 14th of the file is whacked every time whacking
41  // is needed.
42 
43 //const int MAXIMUM_BUFFER_SIZE = 140000;
44  // the maximum allowed chunk that can be copied from the old logfile
45  // to the current one.
46 
47 //int static_chaos() { return chaos().inclusive(0, 1280004); }
48 
49 combo_logger::combo_logger(const astring &filename, int limit, stream_choices target)
50 : file_logger(filename, limit),
51  console_logger(target)
52 {
53 }
54 
55 void combo_logger::add_filter(int new_filter)
56 {
57  file_logger::add_filter(new_filter);
58  console_logger::add_filter(new_filter);
59 }
60 
61 void combo_logger::remove_filter(int old_filter)
62 {
63  file_logger::remove_filter(old_filter);
65 }
66 
68 {
71 }
72 
74 {
75  file_logger::eol(to_set);
76  console_logger::eol(to_set);
77 }
78 
79 outcome combo_logger::log(const base_string &info, int filter)
80 {
81  console_logger::log(info, filter);
82  return file_logger::log(info, filter);
83 }
84 
85 } //namespace.
86 
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
Provides operations commonly needed on file names.
Definition: filename.h:64
virtual void add_filter(int new_filter)
Adds a member to the filter set.
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.
virtual basis::outcome log(const basis::base_string &info, int filter)
sends the string "info" to the standard output device.
virtual textual::parser_bits::line_ending eol()
observes how line endings are to be printed.
Definition: eol_aware.h:34
basis::outcome log(const basis::base_string &info, int filter=basis::ALWAYS_PRINT)
writes information to the log file (if the filename is valid).
virtual void remove_filter(int old_filter)
Removes a member from the filter set.
Definition: filter_set.h:49
virtual void add_filter(int new_filter)
Adds a member to the filter set.
Definition: filter_set.h:43
virtual void clear_filters()
Resets the filter set to be empty.
Definition: filter_set.h:64
line_ending
Line endings is an enumeration of the separator character(s) used for text files.
Definition: parser_bits.h:31
The guards collection helps in testing preconditions and reporting errors.
Definition: array.h:30
A platform independent way to obtain the timestamp of a file.
Definition: byte_filer.cpp:37
A logger that sends to the console screen using the standard output device.
A dynamic container class that holds any kind of object via pointers.
Definition: amorph.h:55