diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2011-11-29 04:52:52 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-05 17:17:50 +0100 |
commit | 53bd23d0e679746b78d0bcf9234e7b99983e6071 (patch) | |
tree | 51dd89aba98e57c026046fdfbe25ba72aab974a6 /src/base | |
parent | a9c3f18ebc1dbb1de5c7c9d1585347ed25cc2b52 (diff) | |
download | usdx-53bd23d0e679746b78d0bcf9234e7b99983e6071.tar.gz usdx-53bd23d0e679746b78d0bcf9234e7b99983e6071.tar.xz usdx-53bd23d0e679746b78d0bcf9234e7b99983e6071.zip |
ported from log4cxx to log4cpp
log4cxx depends on Apache Portable Runtime Utility Library, so we
switch to log4cpp with nearly the same features but with no
dependencies for easier porting to other platforms
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/image.cpp | 7 | ||||
-rw-r--r-- | src/base/image.hpp | 4 | ||||
-rw-r--r-- | src/base/song.cpp | 24 | ||||
-rw-r--r-- | src/base/song.hpp | 4 | ||||
-rw-r--r-- | src/base/songloading/songloader.cpp | 12 | ||||
-rw-r--r-- | src/base/songloading/songloader.hpp | 4 | ||||
-rw-r--r-- | src/base/songloading/songloading_strategy_txt.cpp | 59 | ||||
-rw-r--r-- | src/base/songloading/songloading_strategy_txt.hpp | 4 | ||||
-rw-r--r-- | src/base/stats.hpp | 4 | ||||
-rw-r--r-- | src/base/texture.cpp | 7 | ||||
-rw-r--r-- | src/base/texture.hpp | 3 |
11 files changed, 73 insertions, 59 deletions
diff --git a/src/base/image.cpp b/src/base/image.cpp index 7b06cc3e..753c8ec3 100644 --- a/src/base/image.cpp +++ b/src/base/image.cpp @@ -30,8 +30,8 @@ namespace usdx { - log4cxx::LoggerPtr Image::log = - log4cxx::Logger::getLogger("usdx.base.Image"); + log4cpp::Category& Image::log = + log4cpp::Category::getInstance("usdx.base.Image"); ImageLoadException::ImageLoadException(std::string error) : error(error) @@ -68,7 +68,8 @@ namespace usdx surface = IMG_Load_RW(source, 1); if (surface == NULL) { - LOG4CXX_ERROR(log, "Error loading image: " << filename); + log << log4cpp::Priority::ERROR << + "Error loading image: " << filename; throw ImageLoadException(IMG_GetError()); } } diff --git a/src/base/image.hpp b/src/base/image.hpp index 9e9ea6e4..4c9d911e 100644 --- a/src/base/image.hpp +++ b/src/base/image.hpp @@ -31,7 +31,7 @@ #include <string> #include <boost/filesystem.hpp> #include <SDL/SDL.h> -#include <log4cxx/logger.h> +#include <log4cpp/Category.hh> namespace usdx { @@ -50,7 +50,7 @@ namespace usdx class Image { private: - static log4cxx::LoggerPtr log; + static log4cpp::Category& log; boost::filesystem::wpath filename; SDL_Surface* surface; diff --git a/src/base/song.cpp b/src/base/song.cpp index 209f13de..af7e90a5 100644 --- a/src/base/song.cpp +++ b/src/base/song.cpp @@ -30,8 +30,8 @@ namespace usdx { - log4cxx::LoggerPtr Song::log = - log4cxx::Logger::getLogger("usdx.base.Song"); + log4cpp::Category& Song::log = + log4cpp::Category::getInstance("usdx.base.Song"); const boost::filesystem::wpath& Song::get_filename(void) const { @@ -98,7 +98,7 @@ namespace usdx lyrics.clear(); } - std::string Song::get_header_tag(const std::string& tag, const bool required) + std::string Song::get_header_tag(const std::string& tag, const bool required) { std::map<std::string, std::string>::iterator it; std::string result = ""; @@ -108,9 +108,9 @@ namespace usdx custom_header_tags.erase(it); } else if (required) { - LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << - get_filename() << "'"); - throw MissingTagException(tag, "Incomplete Song! Missing Tag."); + log << log4cpp::Priority::ERROR << "Incomplete Song! Missing '" << + tag << "' Tag in: '" << get_filename() << "'"; + throw MissingTagException(tag, "Incomplete Song! Missing Tag."); } return result; @@ -126,8 +126,8 @@ namespace usdx custom_header_tags.erase(it); } else if (required) { - LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << - get_filename() << "'"); + log << log4cpp::Priority::ERROR << "Incomplete Song! Missing '" << + tag << "' Tag in: '" << get_filename() << "'"; throw MissingTagException(tag, "Incomplete Song! Missing Tag."); } @@ -145,8 +145,8 @@ namespace usdx stream >> result; } else if (required) { - LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << - get_filename() << "'"); + log << log4cpp::Priority::ERROR << "Incomplete Song! Missing '" << + tag << "' Tag in: '" << get_filename() << "'"; throw MissingTagException(tag, "Incomplete Song! Missing Tag."); } @@ -167,8 +167,8 @@ namespace usdx custom_header_tags.erase(it); } else if (required) { - LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << - get_filename() << "'"); + log << log4cpp::Priority::ERROR << "Incomplete Song! Missing '" << + tag << "' Tag in: '" << get_filename() << "'"; throw MissingTagException(tag, "Incomplete Song! Missing Tag."); } diff --git a/src/base/song.hpp b/src/base/song.hpp index c5b160af..afcae7f4 100644 --- a/src/base/song.hpp +++ b/src/base/song.hpp @@ -31,7 +31,7 @@ #include <map> #include <list> #include <boost/filesystem.hpp> -#include <log4cxx/logger.h> +#include <log4cpp/Category.hh> #include "bpm.hpp" #include "lyric_line.hpp" #include "texture.hpp" @@ -60,7 +60,7 @@ namespace usdx class Song { private: - static log4cxx::LoggerPtr log; + static log4cpp::Category& log; boost::filesystem::wpath filename; diff --git a/src/base/songloading/songloader.cpp b/src/base/songloading/songloader.cpp index 5562bdc7..5b46601b 100644 --- a/src/base/songloading/songloader.cpp +++ b/src/base/songloading/songloader.cpp @@ -30,8 +30,8 @@ namespace usdx { - log4cxx::LoggerPtr Songloader::log = - log4cxx::Logger::getLogger("usdx.base.songloading.Songloader"); + log4cpp::Category& Songloader::log = + log4cpp::Category::getInstance("usdx.base.songloading.Songloader"); Songloader *Songloader::instance = NULL; @@ -61,7 +61,9 @@ namespace usdx std::string ext = extension(filename); std::map<std::string, SongloadingStrategyBaseFactory*>::iterator it = strategies.find(ext); if (it == strategies.end()) { - LOG4CXX_WARN(log, "No SongloadingStrategy found for file extension: '" << ext << "'"); + log << log4cpp::Priority::WARN << + "No SongloadingStrategy found for file extension: '" << + ext << "'"; throw NoStrategyException("Unknown file format."); } @@ -73,7 +75,9 @@ namespace usdx std::string ext = extension(song->get_filename()); std::map<std::string, SongloadingStrategyBaseFactory*>::iterator it = strategies.find(ext); if (it == strategies.end()) { - LOG4CXX_WARN(log, "No SongloadingStrategy found for file extension: '" << ext << "'"); + log << log4cpp::Priority::WARN << + "No SongloadingStrategy found for file extension: '" << + ext << "'"; throw NoStrategyException("Unknown file format."); } diff --git a/src/base/songloading/songloader.hpp b/src/base/songloading/songloader.hpp index 4b7150ab..0f9611fe 100644 --- a/src/base/songloading/songloader.hpp +++ b/src/base/songloading/songloader.hpp @@ -29,7 +29,7 @@ #include <map> #include <boost/filesystem.hpp> -#include <log4cxx/logger.h> +#include <log4cpp/Category.hh> #include "song.hpp" #include "utils/base_exception.hpp" #include "songloading_strategy_base_factory.hpp" @@ -46,7 +46,7 @@ namespace usdx class Songloader { private: - static log4cxx::LoggerPtr log; + static log4cpp::Category& log; Songloader(void); diff --git a/src/base/songloading/songloading_strategy_txt.cpp b/src/base/songloading/songloading_strategy_txt.cpp index a7d296a5..d3551144 100644 --- a/src/base/songloading/songloading_strategy_txt.cpp +++ b/src/base/songloading/songloading_strategy_txt.cpp @@ -36,9 +36,9 @@ namespace usdx { - log4cxx::LoggerPtr SongloadingStrategyTxt::log = - log4cxx::Logger::getLogger( - "usdx.base.songloading.SongloadingStrategyTxt"); + log4cpp::Category& SongloadingStrategyTxt::log = + log4cpp::Category::getInstance( + "usdx.base.songloading.SongloadingStrategyTxt"); SongloadingStrategyTxt::SongloadingStrategyTxt(void) { @@ -53,7 +53,8 @@ namespace usdx std::size_t pos = line.find(':'); if (line[0] != '#' || pos == std::string::npos) { - LOG4CXX_DEBUG(log, "Tried to parse invalid header line: '" << line << "'"); + log << log4cpp::Priority::DEBUG << + "Tried to parse invalid header line: '" << line << "'"; throw "Invalid header!"; } @@ -73,14 +74,16 @@ namespace usdx // line is already rtrimmed boost::trim_left(result.second); - LOG4CXX_DEBUG(log, "Found header: '" << result.first << "' with value '" << result.second << "'"); + log << log4cpp::Priority::DEBUG << "Found header: '" << + result.first << "' with value '" << result.second << "'"; return result; } Song* SongloadingStrategyTxt::load_song(Song *song) { - LOG4CXX_DEBUG(log, "Starting loading song from file: " << song->get_filename()); + log << log4cpp::Priority::DEBUG << + "Starting loading song from file: " << song->get_filename(); TextFile file(song->get_filename()); @@ -108,8 +111,10 @@ namespace usdx else if (type == 'E') { // song end if (file.stream().eof()) { - LOG4CXX_WARN(log, "End marker found in line " << line_number << - " before end of file: '" << song->get_filename() << "'."); + log << log4cpp::Priority::WARN << + "End marker found in line " << line_number << + " before end of file: '" << song->get_filename() << + "'."; } return false; @@ -124,14 +129,16 @@ namespace usdx parse_note(song, type, linestream, line_number); } else { - LOG4CXX_WARN(log, "Unknown line in song: '" << line << + log << log4cpp::Priority::WARN << + "Unknown line in song: '" << line << "' in file: " << song->get_filename() << - " at line " << line_number); + " at line " << line_number; } } catch (std::exception &e) { - LOG4CXX_WARN(log, "Error in song file at line " << - line_number << ": " << e.what()); + log << log4cpp::Priority::WARN << + "Error in song file at line " << line_number << ": " << + e.what(); } return true; @@ -145,14 +152,13 @@ namespace usdx linestream >> line_out; if (linestream.good()) { linestream >> line_in; - LOG4CXX_DEBUG(log, "Found newline in line " << - line_number << " with out of last line with " << - line_out << " and in of next line " << line_in); + log << log4cpp::Priority::DEBUG << "Found newline in line " << + line_number << " with out of last line with " << + line_out << " and in of next line " << line_in; } else { - LOG4CXX_DEBUG(log, "Found newline in line " << - line_number << " with out of last line with " << - line_out); + log << log4cpp::Priority::DEBUG << "Found newline in line " << + line_number << " with out of last line with " << line_out; } song->new_line(line_out, line_in); @@ -165,9 +171,9 @@ namespace usdx LocaleIndependentFloat new_bpm; linestream >> beat >> new_bpm; - LOG4CXX_DEBUG(log, "Found new bpm in line " << - line_number << " starting at beat: " << - beat << " and new bpm of " << new_bpm.get_value()); + log << log4cpp::Priority::DEBUG << "Found new bpm in line " << + line_number << " starting at beat: " << beat << + " and new bpm of " << new_bpm.get_value(); song->new_bpm(beat, new_bpm.get_value()); } @@ -182,9 +188,9 @@ namespace usdx getline(linestream, lyric); boost::trim_right_if(lyric, boost::is_cntrl()); - LOG4CXX_DEBUG(log, "Found lyric: '" << lyric << "' at line: " << line_number << - " at beat: " << beat << " with length: " << length << - " at height: " << height); + log << log4cpp::Priority::DEBUG << "Found lyric: '" << lyric << + "' at line: " << line_number << " at beat: " << beat << + " with length: " << length << " at height: " << height; song->new_note(type, beat, length, height, lyric); } @@ -200,7 +206,7 @@ namespace usdx boost::trim(line); boost::trim_if(line, boost::is_cntrl()); - LOG4CXX_DEBUG(log, "Line: " << line); + log << log4cpp::Priority::DEBUG << "Line: " << line; if (header && line[0] == '#') { @@ -221,7 +227,8 @@ namespace usdx } if (! notes_found) { - LOG4CXX_WARN(log, "Song: '" << filename << "' has no notes. Ignoring!"); + log << log4cpp::Priority::WARN << "Song: '" << filename << + "' has no notes. Ignoring!"; throw "No notes."; } diff --git a/src/base/songloading/songloading_strategy_txt.hpp b/src/base/songloading/songloading_strategy_txt.hpp index 293c65e6..5028304b 100644 --- a/src/base/songloading/songloading_strategy_txt.hpp +++ b/src/base/songloading/songloading_strategy_txt.hpp @@ -29,7 +29,7 @@ #include <string> #include <boost/filesystem.hpp> -#include <log4cxx/logger.h> +#include <log4cpp/Category.hh> #include "songloading_strategy.hpp" #include "songloading_strategy_factory.hpp" #include "utils/text_file.hpp" @@ -39,7 +39,7 @@ namespace usdx class SongloadingStrategyTxt : public SongloadingStrategy { private: - static log4cxx::LoggerPtr log; + static log4cpp::Category& log; /** * Split the header field in name and value. diff --git a/src/base/stats.hpp b/src/base/stats.hpp index b3068024..63d3a68e 100644 --- a/src/base/stats.hpp +++ b/src/base/stats.hpp @@ -28,7 +28,7 @@ #define STATS_HPP #include <string> -#include <log4cxx/logger.h> +#include <log4cpp/Category.hh> #include "stats_database.hpp" namespace usdx @@ -39,7 +39,7 @@ namespace usdx class Stats { private: - static log4cxx::LoggerPtr log; + static log4cpp::Category& log; static StatDatabase *db; static std::string filename; diff --git a/src/base/texture.cpp b/src/base/texture.cpp index ee26a5c8..cf24b9ce 100644 --- a/src/base/texture.cpp +++ b/src/base/texture.cpp @@ -28,8 +28,8 @@ namespace usdx { - log4cxx::LoggerPtr Texture::log = - log4cxx::Logger::getLogger("usdx.base.texture"); + log4cpp::Category& Texture::log = + log4cpp::Category::getInstance("usdx.base.texture"); Texture::Texture(boost::filesystem::wpath filename) : filename(filename), texture(0), size(0, 0), rotation(0) @@ -73,7 +73,8 @@ namespace usdx break; default: - LOG4CXX_ERROR(log, "" << filename << " is not in true color! Could not handle that!"); + log << log4cpp::Priority::ERROR << "'" << filename << + "' is not in true color! Could not handle that!"; throw TextureColorDepthException(image.get_surface()->format->BytesPerPixel); } diff --git a/src/base/texture.hpp b/src/base/texture.hpp index 008707d6..fbd88197 100644 --- a/src/base/texture.hpp +++ b/src/base/texture.hpp @@ -29,6 +29,7 @@ #include <boost/filesystem.hpp> #include <GL/gl.h> +#include <log4cpp/Category.hh> #include "utils/point_3d.hpp" #include "utils/dimension.hpp" @@ -68,7 +69,7 @@ namespace usdx class Texture { private: - static log4cxx::LoggerPtr log; + static log4cpp::Category& log; boost::filesystem::wpath filename; |