[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:41:56 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=dc264bc
The following commit has been merged in the master branch:
commit dc264bc00d80ae943a47af9b0613d96e9987f445
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Fri Sep 10 14:02:09 2010 +0000
#476, #614: Introduced class LogMsg for enhanced logging, migrated all existing warnings and error messages (not the exceptions) to use the new logic. Every log message now has a type (debug, info, warning, error). Applications can set a logging level to determine which messages are processed and supply a custom log message handler at runtime. (Based on a contribution by Simson Garfinkel.)
---
src/basicio.cpp | 12 +++----
src/convert.cpp | 75 +++++++++++++++++++-------------------
src/error.cpp | 17 +++++++++
src/error.hpp | 94 +++++++++++++++++++++++++++++++++++++++++++++++-
src/exif.cpp | 12 +++----
src/iptc.cpp | 12 +++----
src/jp2image.cpp | 13 ++++---
src/jpgimage.cpp | 10 +++---
src/pngchunk.cpp | 18 +++++-----
src/pngimage.cpp | 2 +-
src/preview.cpp | 2 +-
src/psdimage.cpp | 8 ++---
src/rw2image.cpp | 4 +--
src/tags.cpp | 7 ++--
src/tiffcomposite.cpp | 80 +++++++++++++++++++----------------------
src/tiffvisitor.cpp | 99 +++++++++++++++++++++++----------------------------
src/value.cpp | 14 ++++----
src/xmp.cpp | 12 +++----
src/xmpsidecar.cpp | 4 +--
19 files changed, 290 insertions(+), 205 deletions(-)
diff --git a/src/basicio.cpp b/src/basicio.cpp
index 315e1bd..44c2a70 100644
--- a/src/basicio.cpp
+++ b/src/basicio.cpp
@@ -571,7 +571,7 @@ namespace Exiv2 {
if (::lstat(pf, &buf1) == -1) {
statOk = false;
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: " << Error(2, pf, strError(), "::lstat") << "
";
+ EXV_WARNING << Error(2, pf, strError(), "::lstat") << "
";
#endif
}
origStMode = buf1.st_mode;
@@ -588,7 +588,7 @@ namespace Exiv2 {
if (::stat(pf, &buf1) == -1) {
statOk = false;
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: " << Error(2, pf, strError(), "::stat") << "
";
+ EXV_WARNING << Error(2, pf, strError(), "::stat") << "
";
#endif
}
origStMode = buf1.st_mode;
@@ -616,14 +616,14 @@ namespace Exiv2 {
if (statOk && ::_wstat(wpf, &buf2) == -1) {
statOk = false;
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: " << Error(2, wpf, strError(), "::_wstat") << "
";
+ EXV_WARNING << Error(2, wpf, strError(), "::_wstat") << "
";
#endif
}
if (statOk && origStMode != buf2.st_mode) {
// Set original file permissions
if (::_wchmod(wpf, origStMode) == -1) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: " << Error(2, wpf, strError(), "::_wchmod") << "
";
+ EXV_WARNING << Error(2, wpf, strError(), "::_wchmod") << "
";
#endif
}
}
@@ -643,14 +643,14 @@ namespace Exiv2 {
if (statOk && ::stat(pf, &buf2) == -1) {
statOk = false;
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: " << Error(2, pf, strError(), "::stat") << "
";
+ EXV_WARNING << Error(2, pf, strError(), "::stat") << "
";
#endif
}
if (statOk && origStMode != buf2.st_mode) {
// Set original file permissions
if (::chmod(pf, origStMode) == -1) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: " << Error(2, pf, strError(), "::chmod") << "
";
+ EXV_WARNING << Error(2, pf, strError(), "::chmod") << "
";
#endif
}
}
diff --git a/src/convert.cpp b/src/convert.cpp
index bd73b59..bab4707 100644
--- a/src/convert.cpp
+++ b/src/convert.cpp
@@ -487,7 +487,7 @@ namespace Exiv2 {
std::string value = pos->toString();
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -504,7 +504,7 @@ namespace Exiv2 {
const CommentValue* cv = dynamic_cast<const CommentValue*>(&pos->value());
if (cv == 0) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -522,7 +522,7 @@ namespace Exiv2 {
std::string value = pos->toString(i);
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -544,14 +544,14 @@ namespace Exiv2 {
std::string value = pos->toString();
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
if (sscanf(value.c_str(), "%d:%d:%d %d:%d:%d", &year, &month, &day, &hour, &min, &sec) != 6) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to
- << ", unable to parse '" << value << "'
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to
+ << ", unable to parse '" << value << "'
";
#endif
return;
}
@@ -570,7 +570,7 @@ namespace Exiv2 {
}
if (!ok) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -583,7 +583,7 @@ namespace Exiv2 {
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -611,15 +611,15 @@ namespace Exiv2 {
}
if (datePos == exifData_->end()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
std::string value = datePos->toString();
if (sscanf(value.c_str(), "%d:%d:%d", &year, &month, &day) != 3) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to
- << ", unable to parse '" << value << "'
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to
+ << ", unable to parse '" << value << "'
";
#endif
return;
}
@@ -694,7 +694,7 @@ namespace Exiv2 {
int value = pos->toLong();
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -715,14 +715,14 @@ namespace Exiv2 {
if (!prepareXmpTarget(to)) return;
if (pos->count() != 3) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
Exiv2::ExifData::iterator refPos = exifData_->findKey(ExifKey(std::string(from) + "Ref"));
if (refPos == exifData_->end()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -732,7 +732,7 @@ namespace Exiv2 {
const int32_t d = pos->toRational(i).second;
if (d == 0) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -760,7 +760,7 @@ namespace Exiv2 {
std::string value;
if (!getTextValue(value, pos)) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -781,7 +781,7 @@ namespace Exiv2 {
std::string value;
if (!getTextValue(value, pos)) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -800,7 +800,7 @@ namespace Exiv2 {
std::string value = pos->toString(i);
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -820,7 +820,7 @@ namespace Exiv2 {
std::string value = pos->toString();
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -830,7 +830,7 @@ namespace Exiv2 {
}
#ifndef SUPPRESS_WARNINGS
catch (const XMP_Error& e) {
- std::cerr << "Warning: Failed to convert " << from << " to " << to << " (" << e.GetErrMsg() << ")
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << " (" << e.GetErrMsg() << ")
";
return;
}
#else
@@ -904,7 +904,7 @@ namespace Exiv2 {
if (erase_) xmpData_->erase(pos);
#else
# ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
# endif
#endif // !EXV_HAVE_XMP_TOOLKIT
}
@@ -917,7 +917,7 @@ namespace Exiv2 {
std::string value = pos->toString();
if (!pos->value().ok() || value.length() < 4) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -940,7 +940,7 @@ namespace Exiv2 {
std::string value = pos->toString();
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -966,7 +966,7 @@ namespace Exiv2 {
value |= fired & 1;
#ifndef SUPPRESS_WARNINGS
else
- std::cerr << "Warning: Failed to convert " << std::string(from) + "/exif:Fired" << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Fired" << " to " << to << "
";
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Return"));
@@ -976,7 +976,7 @@ namespace Exiv2 {
value |= (ret & 3) << 1;
#ifndef SUPPRESS_WARNINGS
else
- std::cerr << "Warning: Failed to convert " << std::string(from) + "/exif:Return" << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Return" << " to " << to << "
";
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Mode"));
@@ -986,7 +986,7 @@ namespace Exiv2 {
value |= (mode & 3) << 3;
#ifndef SUPPRESS_WARNINGS
else
- std::cerr << "Warning: Failed to convert " << std::string(from) + "/exif:Mode" << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Mode" << " to " << to << "
";
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Function"));
@@ -996,7 +996,7 @@ namespace Exiv2 {
value |= (function & 1) << 5;
#ifndef SUPPRESS_WARNINGS
else
- std::cerr << "Warning: Failed to convert " << std::string(from) + "/exif:Function" << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Function" << " to " << to << "
";
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:RedEyeMode"));
@@ -1006,7 +1006,7 @@ namespace Exiv2 {
value |= (red & 1) << 6;
#ifndef SUPPRESS_WARNINGS
else
- std::cerr << "Warning: Failed to convert " << std::string(from) + "/exif:RedEyeMode" << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:RedEyeMode" << " to " << to << "
";
#endif
}
@@ -1022,13 +1022,13 @@ namespace Exiv2 {
std::string value = pos->toString();
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
if (value.empty()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: " << from << " is empty
";
+ EXV_WARNING << from << " is empty
";
#endif
return;
}
@@ -1059,7 +1059,7 @@ namespace Exiv2 {
if ( in.bad() || !(ref == 'N' || ref == 'S' || ref == 'E' || ref == 'W')
|| sep1 != ',' || sep2 != ',' || !in.eof()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -1089,7 +1089,7 @@ namespace Exiv2 {
std::string value = pos->toString();
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
++pos;
continue;
@@ -1115,7 +1115,7 @@ namespace Exiv2 {
std::string value;
if (!getTextValue(value, pos)) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
return;
}
@@ -1131,7 +1131,7 @@ namespace Exiv2 {
std::string value = pos->toString(i);
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: Failed to convert " << from << " to " << to << "
";
+ EXV_WARNING << "Failed to convert " << from << " to " << to << "
";
#endif
continue;
}
@@ -1324,7 +1324,7 @@ namespace Exiv2 {
cd = iconv_open(to, from);
if (cd == (iconv_t)(-1)) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: iconv_open: " << strError() << "
";
+ EXV_WARNING << "iconv_open: " << strError() << "
";
#endif
return false;
}
@@ -1343,9 +1343,8 @@ namespace Exiv2 {
int outbytesProduced = sizeof(outbuf) - 1 - outbytesleft;
if (rc == size_t(-1) && errno != E2BIG) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: iconv: "
- << strError()
- << " inbytesleft = " << inbytesleft << "
";
+ EXV_WARNING << "iconv: " << strError()
+ << " inbytesleft = " << inbytesleft << "
";
#endif
ret = false;
break;
diff --git a/src/error.cpp b/src/error.cpp
index 6d8aada..2507db1 100644
--- a/src/error.cpp
+++ b/src/error.cpp
@@ -34,7 +34,9 @@ EXIV2_RCSID("@(#) $Id$")
#include "i18n.h" // NLS support.
// + standard includes
+#include <iostream>
#include <string>
+#include <cassert>
// *****************************************************************************
namespace {
@@ -111,6 +113,21 @@ namespace {
// class member definitions
namespace Exiv2 {
+ LogMsg::Level LogMsg::level_ = LogMsg::info; // Default output level
+ LogMsg::Handler LogMsg::handler_ = LogMsg::defaultHandler;
+
+ void LogMsg::defaultHandler(int level, const char* s)
+ {
+ switch (static_cast<LogMsg::Level>(level)) {
+ case LogMsg::debug: std::cerr << "Debug: "; break;
+ case LogMsg::info: break;
+ case LogMsg::warn: std::cerr << "Warning: "; break;
+ case LogMsg::error: std::cerr << "Error: "; break;
+ case LogMsg::mute: assert(true);
+ }
+ std::cerr << s;
+ }
+
AnyError::~AnyError() throw()
{
}
diff --git a/src/error.hpp b/src/error.hpp
index 6e1e0dc..c8a27c9 100644
--- a/src/error.hpp
+++ b/src/error.hpp
@@ -20,7 +20,7 @@
*/
/*!
@file error.hpp
- @brief Error class for exceptions
+ @brief Error class for exceptions, log message class
@version $Rev$
@author Andreas Huggel (ahu)
<a href="mailto:ahuggel at gmx.net">ahuggel at gmx.net</a>
@@ -38,6 +38,7 @@
#include <exception>
#include <string>
#include <iosfwd>
+#include <sstream>
// *****************************************************************************
// namespace extensions
@@ -46,6 +47,97 @@ namespace Exiv2 {
// *****************************************************************************
// class definitions
+ /*!
+ @brief Class for a log message, used by the library. Applications can set
+ the log level and provide a customer log message handler (callback
+ function).
+
+ This class is meant to be used as a temporary object like this:
+
+ <code>
+ LogMsg(LogMsg::warn) << "Warning! Something looks fishy.
";
+ </code>
+
+ The convenience macros EXV_DEBUG, EXV_INFO, EXV_WARN and EXV_ERROR
+ are just shorthands for the constructor calls.
+ */
+ class EXIV2API LogMsg {
+ public:
+ /*!
+ @brief Defined log levels. To suppress all log messages, either set the
+ log level to
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list