mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-12-25 21:59:30 +01:00
Added a new (optional) dependency on log4cxx, to enable logging.
If disabled (the default), everything is compiled away.
This commit is contained in:
parent
9ad384eae1
commit
e175a6d8bc
8 changed files with 99 additions and 12 deletions
21
configure.in
21
configure.in
|
@ -50,6 +50,14 @@ if test "${ac_cv_c_Wextra}" != "no"; then
|
||||||
CXXFLAGS+=" -Wextra"
|
CXXFLAGS+=" -Wextra"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl Logging
|
||||||
|
AC_ARG_ENABLE([logging],AC_HELP_STRING([--enable-logging],[logging (default disabled)]))
|
||||||
|
if test "${enable_logging}" = "yes"; then
|
||||||
|
want_logging=1
|
||||||
|
else
|
||||||
|
want_logging=0
|
||||||
|
fi
|
||||||
|
|
||||||
dnl Debug mode
|
dnl Debug mode
|
||||||
AC_ARG_ENABLE([debug],AC_HELP_STRING([--enable-debug],[debug mode (default disabled)]))
|
AC_ARG_ENABLE([debug],AC_HELP_STRING([--enable-debug],[debug mode (default disabled)]))
|
||||||
if test "${enable_debug}" = "yes"; then
|
if test "${enable_debug}" = "yes"; then
|
||||||
|
@ -116,6 +124,19 @@ PKG_CHECK_MODULES(LIBCONFIG, [libconfig++],
|
||||||
AC_DEFINE(HAVE_LIBCONFIG, 1, [Define to 1 if you have the libconfig library])],
|
AC_DEFINE(HAVE_LIBCONFIG, 1, [Define to 1 if you have the libconfig library])],
|
||||||
[has_libconfig=0])
|
[has_libconfig=0])
|
||||||
|
|
||||||
|
dnl Check for liblog4cxx
|
||||||
|
PKG_CHECK_MODULES(LOG4CXX, [liblog4cxx],
|
||||||
|
[has_log4cxx=1
|
||||||
|
AC_DEFINE(HAVE_LIBLOG4CXX, 1, [Define to 1 if you have the liblog4cxx library])],
|
||||||
|
[has_log4cxx=0])
|
||||||
|
AS_IF([test "${want_logging}" = "1"],
|
||||||
|
[AS_IF([test "${has_log4cxx}" = "1"],
|
||||||
|
[with_logging=1
|
||||||
|
AC_DEFINE(USE_LOGGING, 1, [Define to 1 if you want to enable logging])],
|
||||||
|
[AC_MSG_ERROR([Logging requested, but liblog4cxx could not be found on your system (using pkg-config)])])])
|
||||||
|
# Conditional, to avoid a useless dependency (in the case of shared library)
|
||||||
|
AM_CONDITIONAL([WITH_LOGGING], [test "${with_logging}" = "1"])
|
||||||
|
|
||||||
dnl Check for Expat
|
dnl Check for Expat
|
||||||
AX_LIB_EXPAT([2.0.1])
|
AX_LIB_EXPAT([2.0.1])
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,10 @@
|
||||||
noinst_LIBRARIES = libdic.a
|
noinst_LIBRARIES = libdic.a
|
||||||
|
|
||||||
localedir = $(datadir)/locale
|
localedir = $(datadir)/locale
|
||||||
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -I$(top_srcdir) -I../intl -I$(top_srcdir)/intl $(INCICONV)
|
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -I$(top_srcdir) -I../intl -I$(top_srcdir)/intl $(INCICONV) @LOG4CXX_CFLAGS@
|
||||||
|
|
||||||
libdic_a_SOURCES = \
|
libdic_a_SOURCES = \
|
||||||
|
logging.h \
|
||||||
base_exception.cpp base_exception.h \
|
base_exception.cpp base_exception.h \
|
||||||
dic_exception.cpp dic_exception.h \
|
dic_exception.cpp dic_exception.h \
|
||||||
header.cpp header.h \
|
header.cpp header.h \
|
||||||
|
@ -57,5 +58,11 @@ listdic_LDADD=libdic.a @LIBINTL@
|
||||||
regexp_SOURCES=regexpmain.cpp
|
regexp_SOURCES=regexpmain.cpp
|
||||||
regexp_LDADD=libdic.a @LIBINTL@
|
regexp_LDADD=libdic.a @LIBINTL@
|
||||||
|
|
||||||
|
if WITH_LOGGING
|
||||||
|
compdic_LDADD += @LOG4CXX_LIBS@
|
||||||
|
listdic_LDADD += @LOG4CXX_LIBS@
|
||||||
|
regexp_LDADD += @LOG4CXX_LIBS@
|
||||||
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,8 @@
|
||||||
#define fmt(a) boost::format(a)
|
#define fmt(a) boost::format(a)
|
||||||
|
|
||||||
|
|
||||||
|
INIT_LOGGER(CompDic::logger, "Compdic");
|
||||||
|
|
||||||
CompDic::CompDic()
|
CompDic::CompDic()
|
||||||
: m_currentRec(0), m_maxRec(0), m_loadTime(0), m_buildTime(0)
|
: m_currentRec(0), m_maxRec(0), m_loadTime(0), m_buildTime(0)
|
||||||
{
|
{
|
||||||
|
@ -184,15 +186,8 @@ void CompDic::writeNode(uint32_t *ioEdges, unsigned int num, ostream &outFile)
|
||||||
ioEdges[i] = htonl(ioEdges[i]);
|
ioEdges[i] = htonl(ioEdges[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_OUTPUT
|
LOG_TRACE(logger, fmt("writing %1% edges") % num);
|
||||||
cout << fmt(_("writing %1% edges")) % num << endl;
|
|
||||||
for (int i = 0; i < num; i++)
|
|
||||||
{
|
|
||||||
outFile.write((char*)(ioEdges + i), sizeof(DicEdge));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
outFile.write((char*)ioEdges, num * sizeof(DicEdge));
|
outFile.write((char*)ioEdges, num * sizeof(DicEdge));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_EDGES 2000
|
#define MAX_EDGES 2000
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
|
|
||||||
|
#include "logging.h"
|
||||||
#include "header.h"
|
#include "header.h"
|
||||||
#include "dic_internals.h"
|
#include "dic_internals.h"
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ using namespace std;
|
||||||
|
|
||||||
class CompDic
|
class CompDic
|
||||||
{
|
{
|
||||||
|
DEFINE_LOGGER(logger);
|
||||||
typedef boost::unordered_map<vector<DicEdge>, unsigned int> HashMap;
|
typedef boost::unordered_map<vector<DicEdge>, unsigned int> HashMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
51
dic/logging.h
Normal file
51
dic/logging.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*****************************************************************************
|
||||||
|
* Eliot
|
||||||
|
* Copyright (C) 2011 Olivier Teulière
|
||||||
|
* Authors: Olivier Teulière <ipkiss @@ gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DIC_LOGGING_H_
|
||||||
|
#define DIC_LOGGING_H_
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef USE_LOGGING
|
||||||
|
# include <log4cxx/logger.h>
|
||||||
|
|
||||||
|
# define DEFINE_LOGGER(logger) static log4cxx::LoggerPtr logger;
|
||||||
|
# define INIT_LOGGER(logger, name) log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(name))
|
||||||
|
|
||||||
|
# define LOG_TRACE(a, b) LOG4CXX_TRACE(a, b)
|
||||||
|
# define LOG_DEBUG(a, b) LOG4CXX_DEBUG(a, b)
|
||||||
|
# define LOG_INFO(a, b) LOG4CXX_INFO(a, b)
|
||||||
|
# define LOG_WARN(a, b) LOG4CXX_WARN(a, b)
|
||||||
|
# define LOG_ERROR(a, b) LOG4CXX_ERROR(a, b)
|
||||||
|
# define LOG_FATAL(a, b) LOG4CXX_FATAL(a, b)
|
||||||
|
#else
|
||||||
|
# define DEFINE_LOGGER(logger)
|
||||||
|
# define INIT_LOGGER(logger, name)
|
||||||
|
|
||||||
|
# define LOG_TRACE(a, b)
|
||||||
|
# define LOG_DEBUG(a, b)
|
||||||
|
# define LOG_INFO(a, b)
|
||||||
|
# define LOG_WARN(a, b)
|
||||||
|
# define LOG_ERROR(a, b)
|
||||||
|
# define LOG_FATAL(a, b)
|
||||||
|
#endif // USE_LOGGING
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
noinst_LIBRARIES = libgame.a
|
noinst_LIBRARIES = libgame.a
|
||||||
|
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/dic -I../intl -I$(top_srcdir)/intl @LIBCONFIG_CFLAGS@ @ARABICA_CFLAGS@ @EXPAT_CFLAGS@
|
AM_CPPFLAGS = -I$(top_srcdir)/dic -I../intl -I$(top_srcdir)/intl @LIBCONFIG_CFLAGS@ @ARABICA_CFLAGS@ @EXPAT_CFLAGS@ @LOG4CXX_CFLAGS@
|
||||||
|
|
||||||
libgame_a_SOURCES= \
|
libgame_a_SOURCES= \
|
||||||
game_exception.cpp game_exception.h \
|
game_exception.cpp game_exception.h \
|
||||||
|
|
|
@ -20,7 +20,7 @@ localedir = $(datadir)/locale
|
||||||
|
|
||||||
if BUILD_QT
|
if BUILD_QT
|
||||||
|
|
||||||
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" @QT_CFLAGS@ -DQT4LOCALEDIR=\"@QT4LOCALEDIR@\" -I$(top_srcdir) -I../intl -I$(top_srcdir)/dic -I$(top_srcdir)/game
|
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" @QT_CFLAGS@ -DQT4LOCALEDIR=\"@QT4LOCALEDIR@\" -I$(top_srcdir) -I../intl -I$(top_srcdir)/dic -I$(top_srcdir)/game @LOG4CXX_CFLAGS@
|
||||||
|
|
||||||
SUFFIXES=.ui.h .moc.cpp
|
SUFFIXES=.ui.h .moc.cpp
|
||||||
|
|
||||||
|
@ -113,6 +113,10 @@ eliot_LDADD = ../game/libgame.a ../dic/libdic.a @QT_LIBS@ @LIBINTL@ @LIBCONFIG_L
|
||||||
# Needed for proper stack trace handling
|
# Needed for proper stack trace handling
|
||||||
eliot_LDFLAGS = -rdynamic
|
eliot_LDFLAGS = -rdynamic
|
||||||
|
|
||||||
|
if WITH_LOGGING
|
||||||
|
eliot_LDADD += @LOG4CXX_LIBS@
|
||||||
|
endif
|
||||||
|
|
||||||
# Generate a cpp file from the resources
|
# Generate a cpp file from the resources
|
||||||
resources.cpp: eliot.qrc $(RESOURCES)
|
resources.cpp: eliot.qrc $(RESOURCES)
|
||||||
$(RCC) -o $@ $<
|
$(RCC) -o $@ $<
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
localedir = $(datadir)/locale
|
localedir = $(datadir)/locale
|
||||||
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -I$(top_srcdir)/dic -I$(top_srcdir)/game -I../intl -I$(top_srcdir)/intl
|
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -I$(top_srcdir)/dic -I$(top_srcdir)/game -I../intl -I$(top_srcdir)/intl @LOG4CXX_CFLAGS@
|
||||||
|
|
||||||
noinst_PROGRAMS =
|
noinst_PROGRAMS =
|
||||||
bin_PROGRAMS =
|
bin_PROGRAMS =
|
||||||
|
@ -30,11 +30,18 @@ eliottxt_LDADD = $(top_builddir)/game/libgame.a $(top_builddir)/dic/libdic.a @LI
|
||||||
if HAS_READLINE
|
if HAS_READLINE
|
||||||
eliottxt_LDADD += -lreadline
|
eliottxt_LDADD += -lreadline
|
||||||
endif
|
endif
|
||||||
|
if WITH_LOGGING
|
||||||
|
eliottxt_LDADD += @LOG4CXX_LIBS@
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if BUILD_NCURSES
|
if BUILD_NCURSES
|
||||||
bin_PROGRAMS += eliotcurses
|
bin_PROGRAMS += eliotcurses
|
||||||
eliotcurses_SOURCES = ncurses.cpp ncurses.h
|
eliotcurses_SOURCES = ncurses.cpp ncurses.h
|
||||||
eliotcurses_LDADD = ../game/libgame.a ../dic/libdic.a -lncursesw @LIBINTL@ @LIBCONFIG_LIBS@ @ARABICA_LIBS@ @EXPAT_LDFLAGS@
|
eliotcurses_LDADD = ../game/libgame.a ../dic/libdic.a -lncursesw @LIBINTL@ @LIBCONFIG_LIBS@ @ARABICA_LIBS@ @EXPAT_LDFLAGS@
|
||||||
|
if WITH_LOGGING
|
||||||
|
eliotcurses_LDADD += @LOG4CXX_LIBS@
|
||||||
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue