aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--log4cpp.property15
-rw-r--r--log4cxx.xml42
-rw-r--r--src/base/image.cpp7
-rw-r--r--src/base/image.hpp4
-rw-r--r--src/base/song.cpp24
-rw-r--r--src/base/song.hpp4
-rw-r--r--src/base/songloading/songloader.cpp12
-rw-r--r--src/base/songloading/songloader.hpp4
-rw-r--r--src/base/songloading/songloading_strategy_txt.cpp59
-rw-r--r--src/base/songloading/songloading_strategy_txt.hpp4
-rw-r--r--src/base/stats.hpp4
-rw-r--r--src/base/texture.cpp7
-rw-r--r--src/base/texture.hpp3
-rw-r--r--src/frames/loading_frame.cpp4
-rw-r--r--src/frames/loading_frame.hpp4
-rw-r--r--src/menu/application.cpp12
-rw-r--r--src/menu/application.hpp4
-rw-r--r--src/menu/event_manager.cpp6
-rw-r--r--src/menu/event_manager.hpp4
-rw-r--r--test/Makefile2
-rw-r--r--test/base/image.cpp23
-rw-r--r--test/base/songloading.cpp23
-rw-r--r--test/log4cpp.property15
-rw-r--r--test/log4cxx.xml42
25 files changed, 146 insertions, 184 deletions
diff --git a/Makefile b/Makefile
index 94a4c75f..46c41450 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ sources:=$(wildcard $(TOP)/src/*/*/*.cpp) $(wildcard $(TOP)/src/*/*.cpp) $(wildc
deps:=$(sources:.cpp=.d)
CXXFLAGS:=-Wall -Werror -I$(TOP)/src -I$(TOP)/src/base -I$(TOP)/src/menu -I$(TOP)/src/media -I$(TOP)/src/screens -I$(TOP)/src/frames -I$(TOP)/src/utils $(shell pkg-config ftgl --cflags) -g
-LDFLAGS:=-lsqlite3 -lSDL -llog4cxx -lboost_program_options-mt -lboost_filesystem-mt -lboost_thread-mt -lSDL_image -lSDL_gfx -lcppunit -lGL $(shell pkg-config ftgl --libs)
+LDFLAGS:=-lsqlite3 -lSDL $(shell log4cpp-config --libs) -lboost_program_options-mt -lboost_filesystem-mt -lboost_thread-mt -lSDL_image -lSDL_gfx -lcppunit -lGL $(shell pkg-config ftgl --libs)
TARGET:=$(PROJECT)
objects:=$(sources:.cpp=.o)
diff --git a/log4cpp.property b/log4cpp.property
new file mode 100644
index 00000000..4bcad324
--- /dev/null
+++ b/log4cpp.property
@@ -0,0 +1,15 @@
+log4cpp.rootCategory=DEBUG,console
+log4cpp.category.usdx=,roll
+
+log4cpp.appender.console=org.apache.log4j.ConsoleAppender
+log4cpp.appender.console.layout=org.apache.log4j.PatternLayout
+log4cpp.appender.console.layout.ConversionPattern=%-6r [%-5p] %c - %m%n
+log4cpp.appender.console.threshold=ERROR
+
+log4cpp.appender.roll=org.apache.log4j.rolling.RollingFileAppender
+log4cpp.apperder.roll.maximumFileSize=400KB
+log4cpp.apperder.roll.maxBackupIndex=4
+log4cpp.appender.roll.fileName=debug.log
+log4cpp.appender.roll.append=true
+log4cpp.appender.roll.layout=org.apache.log4j.PatternLayout
+log4cpp.appender.roll.layout.ConversionPattern=%-6r [%-5p] %c - %m%n
diff --git a/log4cxx.xml b/log4cxx.xml
deleted file mode 100644
index 75daba46..00000000
--- a/log4cxx.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
-
- <appender name="Roll" class="org.apache.log4j.rolling.RollingFileAppender">
- <triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
- <param name="MaxFileSize" value="400KB" />
- </triggeringPolicy>
-
- <rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
- <param name="MaxIndex" value="4" />
- <param name="FileNamePattern" value="debug.%i.log" />
- </rollingPolicy>
-
- <param name="FileName" value="debug.log" />
-
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%-6r [%-5p] %F:%L - %M - %m%n" />
- </layout>
- </appender>
-
-
- <appender name="Console" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%-6r [%-5p] %F:%-3L - %m%n" />
- </layout>
-
- <filter class="org.apache.log4j.filter.LevelRangeFilter">
- <param name="LevelMin" value="ERROR" />
- </filter>
- </appender>
-
-
- <root>
- <priority value ="ALL" />
- <appender-ref ref="Console" />
- <appender-ref ref="Roll"/>
- </root>
-
-</log4j:configuration>
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;
diff --git a/src/frames/loading_frame.cpp b/src/frames/loading_frame.cpp
index afaa7d0b..fac163d6 100644
--- a/src/frames/loading_frame.cpp
+++ b/src/frames/loading_frame.cpp
@@ -30,8 +30,8 @@
namespace usdx
{
- log4cxx::LoggerPtr LoadingFrame::log =
- log4cxx::Logger::getLogger("usdx.frames.loading_frame");
+ log4cpp::Category& LoadingFrame::log =
+ log4cpp::Category::getInstance("usdx.frames.loading_frame");
LoadingFrame::LoadingFrame() :
Frame(NULL)
diff --git a/src/frames/loading_frame.hpp b/src/frames/loading_frame.hpp
index 5ddf0bf4..80ef0951 100644
--- a/src/frames/loading_frame.hpp
+++ b/src/frames/loading_frame.hpp
@@ -28,14 +28,14 @@
#define LOADING_FRAME_HPP
#include "frame.hpp"
-#include <log4cxx/logger.h>
+#include <log4cpp/Category.hh>
namespace usdx
{
class LoadingFrame : public Frame
{
private:
- static log4cxx::LoggerPtr log;
+ static log4cpp::Category& log;
public:
LoadingFrame();
diff --git a/src/menu/application.cpp b/src/menu/application.cpp
index 37e532a2..d34b8003 100644
--- a/src/menu/application.cpp
+++ b/src/menu/application.cpp
@@ -30,11 +30,12 @@
#include "software_mouse_pointer.hpp"
#include "loading_frame.hpp"
#include <GL/gl.h>
+#include <log4cpp/PropertyConfigurator.hh>
namespace usdx
{
- log4cxx::LoggerPtr Application::log =
- log4cxx::Logger::getLogger("usdx.menu.application");
+ log4cpp::Category& Application::log =
+ log4cpp::Category::getInstance("usdx.menu.application");
Application* Application::instance = NULL;
@@ -43,6 +44,7 @@ namespace usdx
fps_manager(NULL), running(false), display_width(800),
display_height(600), frames_per_second(50)
{
+ log4cpp::PropertyConfigurator::configure("log4cpp.property");
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
}
@@ -119,7 +121,7 @@ namespace usdx
repaint();
SDL_GL_SwapBuffers();
- LOG4CXX_TRACE(log, "repaint");
+ log << log4cpp::Priority::DEBUG << "repaint";
// poll current events
while (event_manager.available() && SDL_PollEvent(&event)) {
@@ -185,8 +187,8 @@ namespace usdx
}
if (! display) {
- LOG4CXX_ERROR(log, "SDL_SetVideoMode failed.");
- throw new std::exception();
+ log << log4cpp::Priority::ERROR << "SDL_SetVideoMode failed.";
+ throw new std::exception();
}
init_fps_manager();
diff --git a/src/menu/application.hpp b/src/menu/application.hpp
index 914eda71..5564c1ad 100644
--- a/src/menu/application.hpp
+++ b/src/menu/application.hpp
@@ -29,7 +29,7 @@
#include <SDL/SDL.h>
#include <SDL/SDL_framerate.h>
-#include <log4cxx/logger.h>
+#include <log4cpp/Category.hh>
#include <list>
#include "drawable_control.hpp"
@@ -40,7 +40,7 @@ namespace usdx
class Application : public DrawableControl
{
private:
- static log4cxx::LoggerPtr log;
+ static log4cpp::Category& log;
static Application* instance;
SDL_Surface* display;
diff --git a/src/menu/event_manager.cpp b/src/menu/event_manager.cpp
index 8f09f202..7359d77c 100644
--- a/src/menu/event_manager.cpp
+++ b/src/menu/event_manager.cpp
@@ -29,8 +29,8 @@
namespace usdx
{
- log4cxx::LoggerPtr EventManager::log =
- log4cxx::Logger::getLogger("usdx.menu.event_manager");
+ log4cpp::Category& EventManager::log =
+ log4cpp::Category::getInstance("usdx.menu.event_manager");
EventManager::EventManager(int capacity) :
buffer(capacity), waiting(0)
@@ -100,7 +100,7 @@ namespace usdx
switch (event.type) {
case SDL_KEYDOWN:
- LOG4CXX_ERROR(log, "key");
+ log << log4cpp::Priority::ERROR << "key";
break;
case SDL_MOUSEMOTION:
diff --git a/src/menu/event_manager.hpp b/src/menu/event_manager.hpp
index bfdda35b..e20950cb 100644
--- a/src/menu/event_manager.hpp
+++ b/src/menu/event_manager.hpp
@@ -38,7 +38,7 @@
#include <boost/thread/thread.hpp>
#include <boost/signals2.hpp>
-#include <log4cxx/logger.h>
+#include <log4cpp/Category.hh>
namespace usdx
{
@@ -52,7 +52,7 @@ namespace usdx
class EventManager
{
private:
- static log4cxx::LoggerPtr log;
+ static log4cpp::Category& log;
EventManager(const EventManager&); //< no copy
EventManager& operator=(const EventManager&); //< no assignment
diff --git a/test/Makefile b/test/Makefile
index b8cd7cbd..61f92e19 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -10,7 +10,7 @@ sources:=$(wildcard *.cpp) $(wildcard */*.cpp) $(wildcard $(TOP)/src/*/*/*.cpp)
deps:=$(sources:.cpp=.d)
CXXFLAGS:=-Wall -Werror -I$(TOP)/src -I$(TOP)/src/base -I$(TOP)/src/menu -I$(TOP)/src/media -I$(TOP)/src/screens -I$(TOP)/src/frames -I$(TOP)/src/utils $(shell pkg-config ftgl --cflags) -g
-LDFLAGS:=-lsqlite3 -lSDL -llog4cxx -lboost_program_options-mt -lboost_filesystem-mt -lboost_thread-mt -lSDL_image -lcppunit -lSDL_gfx -lGL $(shell pkg-config ftgl --libs)
+LDFLAGS:=-lsqlite3 -lSDL $(shell log4cpp-config --libs) -lboost_program_options-mt -lboost_filesystem-mt -lboost_thread-mt -lSDL_image -lSDL_gfx -lcppunit -lGL $(shell pkg-config ftgl --libs)
TARGET:=$(PROJECT)
objects:=$(sources:.cpp=.o)
diff --git a/test/base/image.cpp b/test/base/image.cpp
index 50fb50b0..e9e9d3d4 100644
--- a/test/base/image.cpp
+++ b/test/base/image.cpp
@@ -28,7 +28,7 @@
#include <exception>
#include <cppunit/extensions/HelperMacros.h>
-#include <log4cxx/logger.h>
+#include <log4cpp/Category.hh>
#include <SDL/SDL.h>
@@ -43,7 +43,7 @@ namespace usdx
CPPUNIT_TEST_EXCEPTION(testNotAnImage, usdx::ImageLoadException);
CPPUNIT_TEST_SUITE_END();
private:
- static log4cxx::LoggerPtr log;
+ static log4cpp::Category& log;
public:
void setUp()
{
@@ -57,7 +57,8 @@ namespace usdx
{
Image img("./testdata/test.bmp");
const SDL_Surface *surface = img.get_surface();
- LOG4CXX_DEBUG(log, "test.bmp: w = " << surface->w << "; h = " << surface->h);
+ log << log4cpp::Priority::DEBUG << "test.bmp: " <<
+ "w = " << surface->w << "; h = " << surface->h;
CPPUNIT_ASSERT(40 == surface->w);
CPPUNIT_ASSERT(30 == surface->h);
}
@@ -66,7 +67,8 @@ namespace usdx
{
Image img("./testdata/test.jpg");
const SDL_Surface *surface = img.get_surface();
- LOG4CXX_DEBUG(log, "test.jpg: w = " << surface->w << "; h = " << surface->h);
+ log << log4cpp::Priority::DEBUG << "test.jpg: " <<
+ "w = " << surface->w << "; h = " << surface->h;
CPPUNIT_ASSERT(40 == surface->w);
CPPUNIT_ASSERT(30 == surface->h);
}
@@ -75,7 +77,8 @@ namespace usdx
{
Image img("./testdata/test.png");
const SDL_Surface *surface = img.get_surface();
- LOG4CXX_DEBUG(log, "test.png: w = " << surface->w << "; h = " << surface->h);
+ log << log4cpp::Priority::DEBUG << "test.png: " <<
+ "w = " << surface->w << "; h = " << surface->h;
CPPUNIT_ASSERT(40 == surface->w);
CPPUNIT_ASSERT(30 == surface->h);
}
@@ -84,7 +87,8 @@ namespace usdx
{
Image img("./testdata/test.gif");
const SDL_Surface *surface = img.get_surface();
- LOG4CXX_DEBUG(log, "test.gif: w = " << surface->w << "; h = " << surface->h);
+ log << log4cpp::Priority::DEBUG << "test.gif: " <<
+ "w = " << surface->w << "; h = " << surface->h;
CPPUNIT_ASSERT(40 == surface->w);
CPPUNIT_ASSERT(30 == surface->h);
}
@@ -93,12 +97,13 @@ namespace usdx
{
Image img("./testdata/testsong_correct.txt");
const SDL_Surface *surface = img.get_surface();
- LOG4CXX_DEBUG(log, "testsong_correct.txt: w = " << surface->w << "; h = " << surface->h);
+ log << log4cpp::Priority::DEBUG << "testsong_correct.txt: " <<
+ "w = " << surface->w << "; h = " << surface->h;
}
};
- log4cxx::LoggerPtr ImageTest::log =
- log4cxx::Logger::getLogger("test.usdx.base.image");
+ log4cpp::Category& ImageTest::log =
+ log4cpp::Category::getInstance("test.usdx.base.image");
CPPUNIT_TEST_SUITE_REGISTRATION(ImageTest);
};
diff --git a/test/base/songloading.cpp b/test/base/songloading.cpp
index ddb2756f..94690cc3 100644
--- a/test/base/songloading.cpp
+++ b/test/base/songloading.cpp
@@ -28,7 +28,8 @@
#include <cppunit/extensions/HelperMacros.h>
#include "song.hpp"
#include "songloading/songloader.hpp"
-#include <log4cxx/logger.h>
+#include <log4cpp/Category.hh>
+#include <log4cpp/Priority.hh>
namespace usdx
{
@@ -42,21 +43,19 @@ namespace usdx
CPPUNIT_TEST_SUITE_END();
private:
- int oldLogLevel;
+ log4cpp::Priority::Value oldLogLevel;
public:
void setUp()
{
// save old loglevel in case we want to disable logging
- using namespace log4cxx;
- oldLogLevel = Logger::getRootLogger()->getEffectiveLevel()->toInt();
+ oldLogLevel = log4cpp::Category::getRoot().getPriority();
}
void tearDown()
{
// set old loglevel in case we did disable logging
- using namespace log4cxx;
- Logger::getRootLogger()->setLevel(Level::toLevel(oldLogLevel));
+ log4cpp::Category::getRoot().setPriority(oldLogLevel);
}
void testSongloadingTxtHeader()
@@ -93,8 +92,7 @@ namespace usdx
{
// disable logging to avoid logmsgs when the exeption
// is thrown
- using namespace log4cxx;
- Logger::getRootLogger()->setLevel(Level::getOff());
+ log4cpp::Category::getRoot().setPriority(log4cpp::Priority::EMERG);
Songloader::get_instance()->
load_header("testdata/testsong_missing_artist.txt");
@@ -104,8 +102,7 @@ namespace usdx
{
// disable logging to avoid logmsgs when the exeption
// is thrown
- using namespace log4cxx;
- Logger::getRootLogger()->setLevel(Level::getOff());
+ log4cpp::Category::getRoot().setPriority(log4cpp::Priority::EMERG);
Songloader::get_instance()->
load_header("testdata/testsong_missing_title.txt");
@@ -115,8 +112,7 @@ namespace usdx
{
// disable logging to avoid logmsgs when the exeption
// is thrown
- using namespace log4cxx;
- Logger::getRootLogger()->setLevel(Level::getOff());
+ log4cpp::Category::getRoot().setPriority(log4cpp::Priority::EMERG);
Songloader::get_instance()->
load_header("testdata/testsong_missing_mp3.txt");
@@ -127,8 +123,7 @@ namespace usdx
{
// disable logging to avoid logmsgs when the exeption
// is thrown
- using namespace log4cxx;
- Logger::getRootLogger()->setLevel(Level::getOff());
+ log4cpp::Category::getRoot().setPriority(log4cpp::Priority::EMERG);
Songloader::get_instance()->
load_header("testdata/testsong_missing_bpm.txt");
diff --git a/test/log4cpp.property b/test/log4cpp.property
new file mode 100644
index 00000000..4bcad324
--- /dev/null
+++ b/test/log4cpp.property
@@ -0,0 +1,15 @@
+log4cpp.rootCategory=DEBUG,console
+log4cpp.category.usdx=,roll
+
+log4cpp.appender.console=org.apache.log4j.ConsoleAppender
+log4cpp.appender.console.layout=org.apache.log4j.PatternLayout
+log4cpp.appender.console.layout.ConversionPattern=%-6r [%-5p] %c - %m%n
+log4cpp.appender.console.threshold=ERROR
+
+log4cpp.appender.roll=org.apache.log4j.rolling.RollingFileAppender
+log4cpp.apperder.roll.maximumFileSize=400KB
+log4cpp.apperder.roll.maxBackupIndex=4
+log4cpp.appender.roll.fileName=debug.log
+log4cpp.appender.roll.append=true
+log4cpp.appender.roll.layout=org.apache.log4j.PatternLayout
+log4cpp.appender.roll.layout.ConversionPattern=%-6r [%-5p] %c - %m%n
diff --git a/test/log4cxx.xml b/test/log4cxx.xml
deleted file mode 100644
index 75daba46..00000000
--- a/test/log4cxx.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
-
- <appender name="Roll" class="org.apache.log4j.rolling.RollingFileAppender">
- <triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
- <param name="MaxFileSize" value="400KB" />
- </triggeringPolicy>
-
- <rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
- <param name="MaxIndex" value="4" />
- <param name="FileNamePattern" value="debug.%i.log" />
- </rollingPolicy>
-
- <param name="FileName" value="debug.log" />
-
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%-6r [%-5p] %F:%L - %M - %m%n" />
- </layout>
- </appender>
-
-
- <appender name="Console" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%-6r [%-5p] %F:%-3L - %m%n" />
- </layout>
-
- <filter class="org.apache.log4j.filter.LevelRangeFilter">
- <param name="LevelMin" value="ERROR" />
- </filter>
- </appender>
-
-
- <root>
- <priority value ="ALL" />
- <appender-ref ref="Console" />
- <appender-ref ref="Roll"/>
- </root>
-
-</log4j:configuration>