|
From: Tapio V. <aa...@us...> - 2010-08-12 15:39:32
|
Module: performous
Branch: portaudio
Commit: 679a6acef163b8707084864246f63e9b15ffd1b3
Author: Fredrik Klasson <fr...@li...>
Date: Sun Aug 8 12:51:57 2010 +0200
[ ] Replacing a few std::cout with std::clog. I think those are verbose messages, thus only show up when asked for.
---
game/audio.cc | 2 +-
game/backgrounds.cc | 8 ++++----
game/color.cc | 2 +-
game/configuration.cc | 6 +++---
game/fs.cc | 4 ++--
game/main.cc | 14 +++++++++-----
game/midifile.cc | 2 +-
game/songparser-ini.cc | 2 +-
game/songparser-txt.cc | 2 +-
game/songs.cc | 2 +-
game/unicode.cc | 2 +-
11 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/game/audio.cc b/game/audio.cc
index ae4acfb..fe8f236 100644
--- a/game/audio.cc
+++ b/game/audio.cc
@@ -28,7 +28,7 @@ void Audio::open(std::string const& pdev, std::size_t rate, std::size_t frames)
.set_channels(2)
.set_rate(rate)
.set_frames(frames)
- .set_debug(std::cerr);
+ .set_debug(std::clog);
m_mixer.start(m_rs);
}
diff --git a/game/backgrounds.cc b/game/backgrounds.cc
index 5fe42bd..fe2ea08 100644
--- a/game/backgrounds.cc
+++ b/game/backgrounds.cc
@@ -29,12 +29,12 @@ void Backgrounds::reload_internal() {
Paths paths = getPaths();
for (Paths::iterator it = paths.begin(); m_loading && it != paths.end(); ++it) {
*it /= "backgrounds";
- if (!fs::is_directory(*it)) { std::cout << ">>> Not scanning for backgrounds: " << *it << " (no such directory)" << std::endl; continue; }
- std::cout << ">>> Scanning " << *it << " (for backgrounds)" << std::endl;
+ if (!fs::is_directory(*it)) { std::clog << ">>> Not scanning for backgrounds: " << *it << " (no such directory)" << std::endl; continue; }
+ std::clog << ">>> Scanning " << *it << " (for backgrounds)" << std::endl;
size_t count = m_bgs.size();
reload_internal(*it); // Scan the found folder
size_t diff = m_bgs.size() - count;
- if (diff > 0 && m_loading) std::cout << diff << " backgrounds loaded" << std::endl;
+ if (diff > 0 && m_loading) std::clog << diff << " backgrounds loaded" << std::endl;
}
m_loading = false;
{ // Randomize the order
@@ -47,7 +47,7 @@ void Backgrounds::reload_internal() {
void Backgrounds::reload_internal(fs::path const& parent) {
namespace fs = fs;
- if (std::distance(parent.begin(), parent.end()) > 20) { std::cout << ">>> Not scanning: " << parent.string() << " (maximum depth reached, possibly due to cyclic symlinks)" << std::endl; return; }
+ if (std::distance(parent.begin(), parent.end()) > 20) { std::clog << ">>> Not scanning: " << parent.string() << " (maximum depth reached, possibly due to cyclic symlinks)" << std::endl; return; }
try {
// Find suitable file formats
boost::regex expression("(.*\\.(png|jpeg|jpg|svg))$", boost::regex_constants::icase);
diff --git a/game/color.cc b/game/color.cc
index 09702f0..f5da032 100644
--- a/game/color.cc
+++ b/game/color.cc
@@ -37,7 +37,7 @@ Color::Color(std::string const& str) {
}
ColorNames::Map::const_iterator it = colors.m.find(str);
if (it != colors.m.end()) { *this = it->second; return; }
- std::cerr << "WARNING: Unknown color: " << str << " (using magenta to hilight)" << std::endl;
+ std::clog << "WARNING: Unknown color: " << str << " (using magenta to hilight)" << std::endl;
*this = Color(1.0, 0.0, 1.0);
}
diff --git a/game/configuration.cc b/game/configuration.cc
index f108d4b..6391941 100644
--- a/game/configuration.cc
+++ b/game/configuration.cc
@@ -262,10 +262,10 @@ void readMenuXML(xmlpp::Node* node) {
void readConfigXML(fs::path const& file, int mode) {
if (!fs::exists(file)) {
- std::cout << "Skipping " << file << " (not found)" << std::endl;
+ std::clog << "Skipping " << file << " (not found)" << std::endl;
return;
}
- std::cout << "Parsing " << file << std::endl;
+ std::clog << "Parsing " << file << std::endl;
xmlpp::DomParser domParser(file.string());
try {
xmlpp::NodeSet n = domParser.get_document()->get_root_node()->find("/performous/menu/entry");
@@ -293,7 +293,7 @@ void readConfigXML(fs::path const& file, int mode) {
}
} else {
if (it == config.end()) {
- std::cout << " Entry " << name << " ignored (does not exist in config schema)." << std::endl;
+ std::clog << " Entry " << name << " ignored (does not exist in config schema)." << std::endl;
continue;
}
it->second.update(elem, mode);
diff --git a/game/fs.cc b/game/fs.cc
index a40c545..c675e28 100644
--- a/game/fs.cc
+++ b/game/fs.cc
@@ -132,10 +132,10 @@ bool isThemeResource(fs::path filename){
namespace {
bool pathNotExist(fs::path const& p) {
if (exists(p)) {
- std::cout << ">>> Using data path \"" << p.string() << "\"" << std::endl;
+ std::clog << ">>> Using data path \"" << p.string() << "\"" << std::endl;
return false;
}
- std::cout << ">>> Not using \"" << p.string() << "\" (does not exist)" << std::endl;
+ std::clog << ">>> Not using \"" << p.string() << "\" (does not exist)" << std::endl;
return true;
}
}
diff --git a/game/main.cc b/game/main.cc
index 44fab76..8eaec03 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -39,6 +39,8 @@ bool g_verbose_messages = false;
class VerboseMessageSink : public boost::iostreams::sink {
public:
+ // i.e. make clog like cout, but only if g_verbose_messages is set.
+ // (we could use cerr or any other file if we want)
std::streamsize write(const char* s, std::streamsize n) {
if(g_verbose_messages)
for(std::streamsize i=0; i<n; i++)
@@ -56,6 +58,7 @@ VerboseMessageSink vsm;
static void signalSetup();
extern "C" void quit(int) {
+// shouldn't "not EXIT_SUCCESS" be sent - ^C^C is an abort, not normal termination?
if (g_quit) std::exit(EXIT_SUCCESS); // Instant exit if Ctrl+C is pressed again
g_quit = true;
signalSetup();
@@ -349,6 +352,12 @@ int main(int argc, char** argv) try {
return 1;
}
po::notify(vm);
+
+ // initialize the verbose message sink
+ g_verbose_messages = vm.count("verbose")!=0;
+ sb.open(vsm);
+ std::clog.rdbuf(&sb);
+
if (vm.count("version")) {
// Already printed the version string in the beginning...
return 0;
@@ -414,11 +423,6 @@ int main(int argc, char** argv) try {
return 0;
}
- // initialize the verbose message sink
- g_verbose_messages = vm.count("verbose")!=0;
- sb.open(vsm);
- std::clog.rdbuf(&sb);
-
// Run the game init and main loop
mainLoop(songlist);
return 0; // Do not remove. SDL_Main (which this function is called on some platforms) needs return statement.
diff --git a/game/midifile.cc b/game/midifile.cc
index 8dfa3a8..b3ae920 100644
--- a/game/midifile.cc
+++ b/game/midifile.cc
@@ -80,7 +80,7 @@ MidiStream::Riff::Riff(MidiStream& ms): ms(ms), name(ms.read_bytes(4)), size(ms.
MidiStream::Riff::~Riff() {
#if MIDI_DEBUG_LEVEL > 0
- if (has_more_data()) std::cout << "WARNING: Only " << offset << " of " << size << " bytes read of RIFF chunk " << name << std::endl;
+ if (has_more_data()) std::clog << "WARNING: Only " << offset << " of " << size << " bytes read of RIFF chunk " << name << std::endl;
#endif
ms.f.seekg(pos + size);
}
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index 67e2ce0..b7f1226 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -265,7 +265,7 @@ void SongParser::iniParse() {
std::ostringstream oss;
oss << "WARNING: Skipping " << reversedNoteCount << " reversed note(s) in ";
oss << s.path << s.midifilename << std::endl;
- std::cerr << oss.str(); // More likely to be atomic when written as one string
+ std::clog << oss.str(); // More likely to be atomic when written as one string
}
/*if (s.vocals.notes.empty()) {
Note n;
diff --git a/game/songparser-txt.cc b/game/songparser-txt.cc
index 61dba03..42e88de 100644
--- a/game/songparser-txt.cc
+++ b/game/songparser-txt.cc
@@ -132,7 +132,7 @@ bool SongParser::txtParseNote(std::string line, VocalTrack &vocal) {
else { // Nothing to do, warn and skip
std::ostringstream oss;
oss << "WARNING: Skipping overlapping note in " << m_song.path << m_song.filename << std::endl;
- std::cerr << oss.str(); // More likely to be atomic when written as one string
+ std::clog << oss.str(); // More likely to be atomic when written as one string
return true;
}
} else throw std::runtime_error("The first note has negative timestamp");
diff --git a/game/songs.cc b/game/songs.cc
index 1bdb005..156c779 100644
--- a/game/songs.cc
+++ b/game/songs.cc
@@ -133,7 +133,7 @@ void Songs::filter_internal() {
boost::mutex::scoped_lock l(m_mutex);
// Print messages when loading has finished
if (!m_loading) {
- std::cerr << m_debug.str();
+ std::clog << m_debug.str();
m_debug.str(""); m_debug.clear();
}
m_dirty = false;
diff --git a/game/unicode.cc b/game/unicode.cc
index fa31716..a8faa58 100644
--- a/game/unicode.cc
+++ b/game/unicode.cc
@@ -8,7 +8,7 @@ void convertToUTF8( std::stringstream &_stream, std::string _filename ) {
try {
Glib::convert(_stream.str(), "UTF-8", "UTF-8"); // Test if input is UTF-8
} catch(...) {
- if (!_filename.empty()) std::cerr << "WARNING: " << _filename << " is not UTF-8.\n Assuming CP1252 for now. Use recode CP1252..UTF-8 */*.txt to convert your files." << std::endl;
+ if (!_filename.empty()) std::clog << "WARNING: " << _filename << " is not UTF-8.\n Assuming CP1252 for now. Use recode CP1252..UTF-8 */*.txt to convert your files." << std::endl;
try {
_stream.str(Glib::convert(_stream.str(), "UTF-8", "CP1252")); // Convert from Microsoft CP1252
} catch (...) {
|