Skip to content

Commit 73a658d

Browse files
author
Clement Champetier
committed
Logger: fix build on Windows
* Remove static attribute _logFileName because of a link error with Microsoft Compiler (MSVC). * Currently the log file is named avtranscoder.log
1 parent 7f63c93 commit 73a658d

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/AvTranscoder/log.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ void callbackToWriteInFile( void *ptr, int level, const char *fmt, va_list vl )
1212

1313
// Print line in log file
1414
std::ofstream outputFile;
15-
outputFile.open( Logger::getLogFileName().c_str(), std::ios::out | std::ios::app );
15+
outputFile.open( LOG_FILE, std::ios::out | std::ios::app );
1616
outputFile << line;
1717
outputFile.close();
1818
}
1919

20-
std::string Logger::_logFileName( "avtranscoder.log" );
21-
2220
void Logger::setLogLevel( const int level )
2321
{
2422
av_log_set_level( level );
@@ -60,7 +58,7 @@ void Logger::logInFile()
6058

6159
// clean log file
6260
std::ofstream outputFile;
63-
outputFile.open( Logger::getLogFileName().c_str() );
61+
outputFile.open( LOG_FILE );
6462
outputFile.close();
6563
}
6664

src/AvTranscoder/log.hpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ extern "C" {
1313
namespace avtranscoder
1414
{
1515

16+
#define LOG_FILE "avtranscoder.log"
1617
#define LOG_DEBUG( ... ) { std::stringstream os; os << __VA_ARGS__; Logger::log( AV_LOG_DEBUG, os.str() ); }
1718
#define LOG_INFO( ... ) { std::stringstream os; os << __VA_ARGS__; Logger::log( AV_LOG_INFO, os.str() ); }
1819
#define LOG_WARN( ... ) { std::stringstream os; os << __VA_ARGS__; Logger::log( AV_LOG_WARNING, os.str() ); }
@@ -31,28 +32,17 @@ class AvExport Logger
3132

3233
/**
3334
* @brief Log with the ffmpeg/libav log system
34-
* @note use define LOG_* to log at DEBUG/INFO/WARN/ERROR level
35+
* @note you can use macro LOG_* to log at DEBUG/INFO/WARN/ERROR level
3536
* @param msg: the message will be prefixed by '[avTranscoder - <level>]'
3637
* @param msg: the message will be suffixed by '\n'
3738
*/
3839
static void log( const int level, const std::string& msg );
3940

4041
/**
4142
* @brief Log ffmpeg/libav and avtranscoder informations in a text file.
42-
* @note Default log filename is avtranscoder.log
43-
* @see getLogFileName
44-
* @see setLogFileName
43+
* @note log filename is avtranscoder.log
4544
*/
4645
static void logInFile();
47-
48-
///@{
49-
/// @warning Need to set the expected log filename before calling logInFile
50-
static std::string& getLogFileName() { return _logFileName; }
51-
static void setLogFileName( const std::string& newLogFileName ) { _logFileName = newLogFileName; }
52-
///@}
53-
54-
private:
55-
static std::string _logFileName; ///< Name of the log file
5646
};
5747

5848
}

0 commit comments

Comments
 (0)