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])])
+-------------------------------------------------------------------
+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
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
%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++
*/
-#include <pwd.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <libxml/tree.h>
-#include <string>
-
-#include "config.h"
-
-#ifdef HAVE_LIBBLOCXX
-#include <blocxx/AppenderLogger.hpp>
-#include <blocxx/FileAppender.hpp>
-#include <blocxx/Logger.hpp>
-#include <blocxx/LogMessage.hpp>
-#endif
-
#include "snapper/Log.h"
#include "snapper/AppUtil.h"
{
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");
}
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);
- }
-
}
/*
- * Copyright (c) [2004-2011] Novell, Inc.
+ * Copyright (c) [2004-2012] Novell, Inc.
*
* All Rights Reserved.
*
#define SNAPPER_LOG_H
#include <sstream>
-#include <string>
+
+#include "Logger.h"
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);
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)
--- /dev/null
+/*
+ * 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 <pwd.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <libxml/tree.h>
+#include <string>
+
+#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);
+ }
+
+}
--- /dev/null
+/*
+ * 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 <string>
+
+
+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
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 \
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
Snapshot.h \
File.h \
Comparison.h \
- Exception.h
+ Exception.h \
+ Logger.h