1
// ------------------------------------------------------------------------
2
// eca-logger-wellformed.cpp: Logging implementation that outputs
3
// messages in a well-formed format.
4
// Copyright (C) 2002-2004 Kai Vehmanen
7
// eca-style-version: 3
9
// This program is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU General Public License as published by
11
// the Free Software Foundation; either version 2 of the License, or
12
// (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
// ------------------------------------------------------------------------
31
#include <kvu_numtostr.h>
33
#include "eca-logger-wellformed.h"
37
ECA_LOGGER_WELLFORMED::ECA_LOGGER_WELLFORMED(void)
41
ECA_LOGGER_WELLFORMED::~ECA_LOGGER_WELLFORMED(void)
46
* Prints the given log message in well-formed
49
* See section "Ecasound Interactive Mode -
50
* Well-Formed Output Mode" in the Ecasound
51
* Programmer's Guide for more detailed documentation.
53
void ECA_LOGGER_WELLFORMED::do_msg(ECA_LOGGER::Msg_level_t level, const string& module_name, const string& log_message)
55
if (is_log_level_set(level) == true) {
56
cout << ECA_LOGGER_WELLFORMED::create_wellformed_message(level,
61
void ECA_LOGGER_WELLFORMED::do_flush(void)
65
void ECA_LOGGER_WELLFORMED::do_log_level_changed(void)
69
string ECA_LOGGER_WELLFORMED::create_wellformed_message(ECA_LOGGER::Msg_level_t level, const string& message)
71
string result, rettype;
72
string::const_iterator p = message.begin();
73
size_t msglen = message.size();
76
result += kvu_numtostr(static_cast<int>(level));
81
if (level == ECA_LOGGER::eiam_return_values) {
82
while(p != message.end()) {
84
if (isspace(*p) != 0) {
85
rettype = string(message.begin(), p);
86
p++; /* skip space to reach start of actual msg */
94
result += kvu_numtostr(msglen);
96
if (level == ECA_LOGGER::eiam_return_values) {
104
/* 6. contentblock */
106
result += string(p,message.end());
107
result += "\r\n\r\n";