mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Added a CMake option that allows to show debug messages in release mode
This commit is contained in:
parent
12953b3fdc
commit
2f29ed003c
@ -90,6 +90,11 @@ if(WITH_MP4)
|
||||
set(TAGLIB_WITH_MP4 TRUE)
|
||||
endif()
|
||||
|
||||
option(TRACE_IN_RELEASE "Output debug messages even in release mode" OFF)
|
||||
if(TRACE_IN_RELEASE)
|
||||
set(TAGLIB_TRACE_IN_RELEASE TRUE)
|
||||
endif()
|
||||
|
||||
configure_file(taglib/taglib_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/taglib_config.h)
|
||||
|
||||
add_subdirectory(taglib)
|
||||
|
@ -3,3 +3,4 @@
|
||||
#define TAGLIB_WITH_ASF 1
|
||||
#define TAGLIB_WITH_MP4 1
|
||||
|
||||
#cmakedefine TAGLIB_TRACE_IN_RELEASE 1
|
||||
|
@ -24,6 +24,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "taglib_config.h"
|
||||
|
||||
#include "tdebug.h"
|
||||
#include "tstring.h"
|
||||
@ -67,11 +68,17 @@ namespace
|
||||
|
||||
void TagLib::debug(const String &s)
|
||||
{
|
||||
#if !defined(NDEBUG) || defined(TAGLIB_TRACE_IN_RELEASE)
|
||||
|
||||
getDebugListener()->printMessage("TagLib: " + s + "\n");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void TagLib::debugData(const ByteVector &v)
|
||||
{
|
||||
#if !defined(NDEBUG) || defined(TAGLIB_TRACE_IN_RELEASE)
|
||||
|
||||
for(size_t i = 0; i < v.size(); ++i)
|
||||
{
|
||||
String msg
|
||||
@ -85,4 +92,6 @@ void TagLib::debugData(const ByteVector &v)
|
||||
|
||||
getDebugListener()->printMessage(msg);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -25,12 +25,11 @@
|
||||
|
||||
#include "tdebuglistener.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
# include <iostream>
|
||||
# include <bitset>
|
||||
# ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# endif
|
||||
#include <iostream>
|
||||
#include <bitset>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
using namespace TagLib;
|
||||
@ -42,8 +41,7 @@ namespace
|
||||
public:
|
||||
virtual void printMessage(const String &msg)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
# ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
const wstring wstr = msg.toWString();
|
||||
const int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL);
|
||||
@ -54,13 +52,11 @@ namespace
|
||||
std::cerr << std::string(&buf[0]);
|
||||
}
|
||||
|
||||
|
||||
# else
|
||||
#else
|
||||
|
||||
std::cerr << msg;
|
||||
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user