feisty meow concerns codebase 2.140
console_logger.cpp
Go to the documentation of this file.
1/*****************************************************************************\
2* *
3* Name : console_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 "console_logger.h"
16#include "logging_filters.h"
17
18#include <textual/parser_bits.h>
19
20#include <stdio.h>
21
22using namespace basis;
23using namespace textual;
24
25namespace loggers {
26
28{}
29
31
32outcome console_logger::log(const base_string &info, int filter)
33{
34
35if (filter) {} //temp ignored
36
37 FILE *log_to = stdout;
38 if (c_target == TO_STDERR) log_to = stderr;
39 if (member(filter)) {
40 // format the output with %s to ensure we get all characters, rather
41 // than having some get interpreted if we used info as the format spec.
42 fprintf(log_to, "%s", (char *)info.observe());
43 // send the EOL char if the style is appropriate for that.
44 if (eol() != parser_bits::NO_ENDING) fprintf(log_to, "%s", get_ending().s());
45 // write immediately to avoid lost output on crash.
46 fflush(log_to);
47 }
48 return common::OKAY;
49}
50
51} //namespace.
52
53
Defines the base class for all string processing objects in hoople.
Definition base_string.h:28
virtual const char * observe() const =0
observes the underlying pointer to the zero-terminated string.
Outcomes describe the state of completion for an operation.
Definition outcome.h:31
virtual basis::outcome log(const basis::base_string &info, int filter)
sends the string "info" to the standard output device.
console_logger(stream_choices log_target=TO_STDOUT)
if "standard_error" is true, than stderr is used instead of stdout.
virtual textual::parser_bits::line_ending eol()
observes how line endings are to be printed.
Definition eol_aware.h:34
virtual basis::astring get_ending()
returns a string for the current ending.
Definition eol_aware.h:40
virtual bool member(int filter_to_check)
Returns true if the "filter_to_check" is a member of the filter set.
Definition filter_set.h:57
@ NO_ENDING
No additional characters added as line endings.
Definition parser_bits.h:34
The guards collection helps in testing preconditions and reporting errors.
Definition array.h:30
A logger that sends to the console screen using the standard output device.