From: Arvin Schnell Date: Tue, 12 Jun 2012 08:17:23 +0000 (+0200) Subject: - removed blocxx (fate #313242) X-Git-Tag: v0.1.3~219^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25161964a5bed0c9092b489fac5476dfc10fa5e0;p=thirdparty%2Fsnapper.git - removed blocxx (fate #313242) --- diff --git a/LIBVERSION b/LIBVERSION index bc80560f..dc1e644a 100644 --- a/LIBVERSION +++ b/LIBVERSION @@ -1 +1 @@ -1.5.0 +1.6.0 diff --git a/VERSION b/VERSION index 7c1886bb..2cfabea2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.10 +0.0.11 diff --git a/configure.in b/configure.in index 44c4d772..08521838 100644 --- a/configure.in +++ b/configure.in @@ -25,12 +25,6 @@ AM_PATH_PYTHON AC_PREFIX_DEFAULT(/usr) -dnl Check for blocxx -AC_CHECK_LIB(blocxx, main, - AC_SUBST([LIBBLOCXX], ["-lblocxx"]) - AC_DEFINE([HAVE_LIBBLOCXX], [1], - [Define if you have libblocxx])) - dnl Automake 1.11 enables silent compilation dnl Disable it by "configure --disable-silent-rules" or "make V=1" m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff --git a/package/snapper.changes b/package/snapper.changes index aa004491..92b9a4cf 100644 --- a/package/snapper.changes +++ b/package/snapper.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Jun 12 10:07:08 CEST 2012 - aschnell@suse.de + +- removed blocxx (fate #313242) +- 0.0.11 + ------------------------------------------------------------------- Thu Mar 15 10:56:40 CET 2012 - aschnell@suse.de diff --git a/snapper.spec.in b/snapper.spec.in index 03c50a51..3e45e424 100644 --- a/snapper.spec.in +++ b/snapper.spec.in @@ -27,12 +27,9 @@ Patch1: no-readonly.diff Prefix: /usr BuildRequires: boost-devel doxygen gcc-c++ libtool libxml2-devel BuildRequires: python-devel swig -%if 0%{?suse_version} -BuildRequires: libblocxx-devel -%if 0%{?suse_version} >= 1210 +%if (0%{?suse_version} && 0%{?suse_version} >= 1210) BuildRequires: libzypp(plugin:commit) %endif -%endif Requires: libsnapper@LIBVERSION_MAJOR@ = %version %if 0%{?suse_version} Recommends: cron logrotate snapper-zypp-plugin @@ -140,9 +137,6 @@ Authors: %package -n libsnapper-devel Requires: libsnapper@LIBVERSION_MAJOR@ = %version Requires: gcc-c++ libstdc++-devel boost-devel libxml2-devel -%if 0%{?suse_version} -Requires: blocxx-devel -%endif Summary: Header files and documentation for libsnapper Group: Development/Languages/C and C++ diff --git a/snapper/Log.cc b/snapper/Log.cc index edaee4aa..66d4f5da 100644 --- a/snapper/Log.cc +++ b/snapper/Log.cc @@ -20,21 +20,6 @@ */ -#include -#include -#include -#include -#include - -#include "config.h" - -#ifdef HAVE_LIBBLOCXX -#include -#include -#include -#include -#endif - #include "snapper/Log.h" #include "snapper/AppUtil.h" @@ -43,113 +28,11 @@ namespace snapper { using namespace std; -#ifdef HAVE_LIBBLOCXX - - using namespace blocxx; - - static const String component = "libsnapper"; - -#else - - string filename; - -#endif - - - void createLogger(const string& name, const string& logpath, const string& logfile) - { -#ifdef HAVE_LIBBLOCXX - - try - { - if (logpath != "NULL" && logfile != "NULL") - { - String nm = name.c_str(); - LoggerConfigMap configItems; - LogAppenderRef logApp; - if (logpath != "STDERR" && logfile != "STDERR" && - logpath != "SYSLOG" && logfile != "SYSLOG") - { - String StrKey; - String StrPath; - StrKey.format("log.%s.location", name.c_str()); - StrPath = (logpath + "/" + logfile).c_str(); - configItems[StrKey] = StrPath; - logApp = - LogAppender::createLogAppender(nm, LogAppender::ALL_COMPONENTS, - LogAppender::ALL_CATEGORIES, - "%d %-5p %c(%P) %F(%M):%L - %m", - LogAppender::TYPE_FILE, - configItems); - } - else if (logpath == "STDERR" && logfile == "STDERR") - { - logApp = - LogAppender::createLogAppender(nm, LogAppender::ALL_COMPONENTS, - LogAppender::ALL_CATEGORIES, - "%d %-5p %c(%P) %F(%M):%L - %m", - LogAppender::TYPE_STDERR, - configItems); - } - else - { - logApp = - LogAppender::createLogAppender(nm, LogAppender::ALL_COMPONENTS, - LogAppender::ALL_CATEGORIES, - "%d %-5p %c(%P) %F(%M):%L - %m", - LogAppender::TYPE_SYSLOG, - configItems); - } - - LogAppender::setDefaultLogAppender(logApp); - } - } - catch (const LoggerException& e) - { - } - -#else - - filename = logpath + "/" + logfile; - -#endif - } - bool testLogLevel(LogLevel level) { -#ifdef HAVE_LIBBLOCXX - - try - { - ELogLevel curLevel = LogAppender::getCurrentLogAppender()->getLogLevel(); - - switch (level) - { - case DEBUG: - return false; // curLevel >= E_DEBUG_LEVEL; - case MILESTONE: - return curLevel >= E_INFO_LEVEL; - case WARNING: - return curLevel >= E_WARNING_LEVEL; - case ERROR: - return curLevel >= E_ERROR_LEVEL; - default: - return curLevel >= E_FATAL_ERROR_LEVEL; - } - } - catch (const LoggerException& e) - { - } - - return false; - -#else - - return level != DEBUG; - -#endif + return callLogQuery(level, "libsnapper"); } @@ -175,133 +58,8 @@ namespace snapper logStreamClose(LogLevel level, const char* file, unsigned line, const char* func, ostringstream* stream) { -#ifdef HAVE_LIBBLOCXX - - ELogLevel curLevel = LogAppender::getCurrentLogAppender()->getLogLevel(); - String category; - - switch (level) - { - case DEBUG: - if (curLevel >= E_DEBUG_LEVEL) - category = Logger::STR_DEBUG_CATEGORY; - break; - case MILESTONE: - if (curLevel >= E_INFO_LEVEL) - category = Logger::STR_INFO_CATEGORY; - break; - case WARNING: - if (curLevel >= E_WARNING_LEVEL) - category = Logger::STR_WARNING_CATEGORY; - break; - case ERROR: - if (curLevel >= E_ERROR_LEVEL) - category = Logger::STR_ERROR_CATEGORY; - break; - default: - if (curLevel >= E_FATAL_ERROR_LEVEL) - category = Logger::STR_FATAL_CATEGORY; - break; - } - - if (!category.empty()) - { - try - { - string tmp = stream->str(); - - string::size_type pos1 = 0; - - while (true) - { - string::size_type pos2 = tmp.find('\n', pos1); - - if (pos2 != string::npos || pos1 != tmp.length()) - LogAppender::getCurrentLogAppender()->logMessage(LogMessage(component, category, - String(tmp.substr(pos1, pos2 - pos1)), - file, line, func)); - - if (pos2 == string::npos) - break; - - pos1 = pos2 + 1; - } - } - catch (const LoggerException& e) - { - } - } - -#else - - static const char* ln[4] = { "DEB", "MIL", "WAR", "ERR" }; - - string prefix = sformat("%s %s libsnapper(%d) %s(%s):%d", datetime(time(0), false, true).c_str(), - ln[level], getpid(), file, func, line); - - FILE* f = fopen(filename.c_str(), "a"); - - string tmp = stream->str(); - - string::size_type pos1 = 0; - - while (true) - { - string::size_type pos2 = tmp.find('\n', pos1); - - if (pos2 != string::npos || pos1 != tmp.length()) - fprintf(f, "%s - %s\n", prefix.c_str(), tmp.substr(pos1, pos2 - pos1).c_str()); - - if (pos2 == string::npos) - break; - - pos1 = pos2 + 1; - } - - fclose(f); - -#endif - + callLogDo(level, "libsnapper", file, line, func, stream->str()); delete stream; } - - void - xml_error_func(void* ctx, const char* msg, ...) - { - } - - xmlGenericErrorFunc xml_error_func_ptr = &xml_error_func; - - - void initDefaultLogger() - { - string path; - string file; - - if (geteuid()) - { - struct passwd* pw = getpwuid(geteuid()); - if (pw) - { - path = pw->pw_dir; - file = "snapper.log"; - } - else - { - path = "/"; - file = "snapper.log"; - } - } - else - { - path = "/var/log"; - file = "snapper.log"; - } - - createLogger("default", path, file); - - initGenericErrorDefaultFunc(&xml_error_func_ptr); - } - } diff --git a/snapper/Log.h b/snapper/Log.h index 374ab569..9e411428 100644 --- a/snapper/Log.h +++ b/snapper/Log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2004-2011] Novell, Inc. + * Copyright (c) [2004-2012] Novell, Inc. * * All Rights Reserved. * @@ -24,7 +24,8 @@ #define SNAPPER_LOG_H #include -#include + +#include "Logger.h" namespace snapper @@ -32,10 +33,6 @@ namespace snapper using std::string; - enum LogLevel { DEBUG, MILESTONE, WARNING, ERROR }; - - void createLogger(const string& name, const string& logpath, const string& logfile); - bool testLogLevel(LogLevel level); void prepareLogStream(std::ostringstream& stream); @@ -45,8 +42,6 @@ namespace snapper void logStreamClose(LogLevel level, const char* file, unsigned line, const char* func, std::ostringstream*); - void initDefaultLogger(); - #define y2deb(op) y2log_op(snapper::DEBUG, __FILE__, __LINE__, __FUNCTION__, op) #define y2mil(op) y2log_op(snapper::MILESTONE, __FILE__, __LINE__, __FUNCTION__, op) #define y2war(op) y2log_op(snapper::WARNING, __FILE__, __LINE__, __FUNCTION__, op) diff --git a/snapper/Logger.cc b/snapper/Logger.cc new file mode 100644 index 00000000..3000a591 --- /dev/null +++ b/snapper/Logger.cc @@ -0,0 +1,148 @@ +/* + * Copyright (c) [2004-2012] Novell, Inc. + * + * All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as published + * by the Free Software Foundation. + * + * 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, contact Novell, Inc. + * + * To contact Novell about this file by physical or electronic mail, you may + * find current contact information at www.novell.com. + */ + + +#include +#include +#include +#include +#include + +#include "config.h" + +#include "snapper/Log.h" +#include "snapper/AppUtil.h" + + +namespace snapper +{ + using namespace std; + + + string filename = "/var/log/snapper.log"; + + LogDo log_do = NULL; + + LogQuery log_query = NULL; + + + void + setLogDo(LogDo new_log_do) + { + log_do = new_log_do; + } + + + void + setLogQuery(LogQuery new_log_query) + { + log_query = new_log_query; + } + + + static void + simple_log_do(LogLevel level, const char* component, const char* file, int line, + const char* func, const string& text) + { + static const char* ln[4] = { "DEB", "MIL", "WAR", "ERR" }; + + string prefix = sformat("%s %s libsnapper(%d) %s(%s):%d", datetime(time(0), false, true).c_str(), + ln[level], getpid(), file, func, line); + + FILE* f = fopen(filename.c_str(), "a"); + if (f) + { + string tmp = text; + + string::size_type pos1 = 0; + + while (true) + { + string::size_type pos2 = tmp.find('\n', pos1); + + if (pos2 != string::npos || pos1 != tmp.length()) + fprintf(f, "%s - %s\n", prefix.c_str(), tmp.substr(pos1, pos2 - pos1).c_str()); + + if (pos2 == string::npos) + break; + + pos1 = pos2 + 1; + } + + fclose(f); + } + } + + + static bool + simple_log_query(LogLevel level, const char* component) + { + return level != DEBUG; + } + + + void + callLogDo(LogLevel level, const char* component, const char* file, int line, + const char* func, const string& text) + { + if (log_do) + (log_do)(level, component, file, line, func, text); + else + simple_log_do(level, component, file, line, func, text); + } + + + bool + callLogQuery(LogLevel level, const char* component) + { + if (log_query) + return (log_query)(level, component); + else + return simple_log_query(level, component); + } + + + void + xml_error_func(void* ctx, const char* msg, ...) + { + } + + xmlGenericErrorFunc xml_error_func_ptr = &xml_error_func; + + + void + initDefaultLogger() + { + filename = "/var/log/snapper.log"; + + if (geteuid()) + { + struct passwd* pw = getpwuid(geteuid()); + if (pw) + { + filename = string(pw->pw_dir) + "/.snapper.log"; + } + } + + initGenericErrorDefaultFunc(&xml_error_func_ptr); + } + +} diff --git a/snapper/Logger.h b/snapper/Logger.h new file mode 100644 index 00000000..99d10fca --- /dev/null +++ b/snapper/Logger.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2011-2012] Novell, Inc. + * + * All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as published + * by the Free Software Foundation. + * + * 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, contact Novell, Inc. + * + * To contact Novell about this file by physical or electronic mail, you may + * find current contact information at www.novell.com. + */ + + +#ifndef SNAPPER_LOGGER_H +#define SNAPPER_LOGGER_H + +#include + + +namespace snapper +{ + using std::string; + + + enum LogLevel { DEBUG, MILESTONE, WARNING, ERROR }; + + /* + * Called function should be able to split content at newlines. + */ + typedef void (*LogDo)(LogLevel level, const char* component, const char* file, int line, + const char* func, const string& content); + + typedef bool (*LogQuery)(LogLevel level, const char* component); + + void setLogDo(LogDo log_do); + + void setLogQuery(LogQuery log_query); + + void callLogDo(LogLevel level, const char* component, const char* file, int line, + const char* func, const string& text); + + bool callLogQuery(LogLevel level, const char* component); + + void initDefaultLogger(); + +} + +#endif diff --git a/snapper/Makefile.am b/snapper/Makefile.am index f6fd7a36..6a528fe3 100644 --- a/snapper/Makefile.am +++ b/snapper/Makefile.am @@ -17,6 +17,7 @@ libsnapper_la_SOURCES = \ Enum.cc Enum.h \ AppUtil.cc AppUtil.h \ Log.cc Log.h \ + Logger.cc Logger.h \ Compare.cc Compare.h \ SystemCmd.cc SystemCmd.h \ AsciiFile.cc AsciiFile.h \ @@ -27,7 +28,7 @@ libsnapper_la_SOURCES = \ SnapperDefines.h libsnapper_la_LDFLAGS = -version-info @LIBVERSION_INFO@ -libsnapper_la_LIBADD = @LIBBLOCXX@ -lxml2 -lz -lm +libsnapper_la_LIBADD = -lxml2 -lz -lm pkgincludedir = $(includedir)/snapper @@ -37,5 +38,6 @@ pkginclude_HEADERS = \ Snapshot.h \ File.h \ Comparison.h \ - Exception.h + Exception.h \ + Logger.h