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
22
using namespace
basis
;
23
using namespace
textual
;
24
25
namespace
loggers
{
26
27
console_logger::console_logger
(
stream_choices
target) : c_target(target)
28
{}
29
30
console_logger::~console_logger
() {}
31
32
outcome
console_logger::log
(
const
base_string
&info,
int
filter)
33
{
34
35
if
(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
basis::base_string
Defines the base class for all string processing objects in hoople.
Definition
base_string.h:28
basis::base_string::observe
virtual const char * observe() const =0
observes the underlying pointer to the zero-terminated string.
basis::outcome
Outcomes describe the state of completion for an operation.
Definition
outcome.h:31
loggers::console_logger::~console_logger
virtual ~console_logger()
Definition
console_logger.cpp:30
loggers::console_logger::log
virtual basis::outcome log(const basis::base_string &info, int filter)
sends the string "info" to the standard output device.
Definition
console_logger.cpp:32
loggers::console_logger::console_logger
console_logger(stream_choices log_target=TO_STDOUT)
if "standard_error" is true, than stderr is used instead of stdout.
Definition
console_logger.cpp:27
loggers::console_logger::stream_choices
stream_choices
Definition
console_logger.h:35
loggers::console_logger::TO_STDERR
@ TO_STDERR
Definition
console_logger.h:35
loggers::eol_aware::eol
virtual textual::parser_bits::line_ending eol()
observes how line endings are to be printed.
Definition
eol_aware.h:34
loggers::eol_aware::get_ending
virtual basis::astring get_ending()
returns a string for the current ending.
Definition
eol_aware.h:40
loggers::filter_set::member
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
textual::parser_bits::NO_ENDING
@ NO_ENDING
No additional characters added as line endings.
Definition
parser_bits.h:34
console_logger.h
logging_filters.h
basis
The guards collection helps in testing preconditions and reporting errors.
Definition
array.h:30
loggers
A logger that sends to the console screen using the standard output device.
Definition
combo_logger.cpp:36
textual
Definition
byte_formatter.cpp:38
parser_bits.h
nucleus
library
loggers
console_logger.cpp
Generated by
1.9.8