Skip to content

Commit da0b29f

Browse files
author
Clement Champetier
committed
Logger: log function doesn't need level as string
1 parent 038078a commit da0b29f

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

src/AvTranscoder/common.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,29 @@ void Logger::setLogLevel( const int level )
1717
av_log_set_level( level );
1818
}
1919

20-
void Logger::log( int level, const std::string& levelStr, const std::string& msg )
20+
void Logger::log( int level, const std::string& msg )
2121
{
2222
std::string avTranscoderMsg( "[avTranscoder - " );
23+
24+
std::string levelStr;
25+
switch( level )
26+
{
27+
case AV_LOG_DEBUG:
28+
levelStr = "debug";
29+
break;
30+
case AV_LOG_INFO:
31+
levelStr = "info";
32+
break;
33+
case AV_LOG_WARNING:
34+
levelStr = "warning";
35+
break;
36+
case AV_LOG_ERROR:
37+
levelStr = "error";
38+
break;
39+
default:
40+
break;
41+
}
42+
2343
avTranscoderMsg += levelStr;
2444
avTranscoderMsg += "] ";
2545
avTranscoderMsg += msg;

src/AvTranscoder/common.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ typedef AVRational Rational;
5959
/// Register all the codecs and formats which are enabled at configuration time.
6060
void AvExport preloadCodecsAndFormats();
6161

62-
#define LOG_DEBUG( ... ) { std::stringstream os; os << __VA_ARGS__; Logger::log( AV_LOG_DEBUG, "debug", os.str() ); }
63-
#define LOG_INFO( ... ) { std::stringstream os; os << __VA_ARGS__; Logger::log( AV_LOG_INFO, "info", os.str() ); }
64-
#define LOG_WARN( ... ) { std::stringstream os; os << __VA_ARGS__; Logger::log( AV_LOG_WARNING, "warning", os.str() ); }
65-
#define LOG_ERROR( ... ) { std::stringstream os; os << __VA_ARGS__; Logger::log( AV_LOG_ERROR, "error", os.str() ); }
62+
#define LOG_DEBUG( ... ) { std::stringstream os; os << __VA_ARGS__; Logger::log( AV_LOG_DEBUG, os.str() ); }
63+
#define LOG_INFO( ... ) { std::stringstream os; os << __VA_ARGS__; Logger::log( AV_LOG_INFO, os.str() ); }
64+
#define LOG_WARN( ... ) { std::stringstream os; os << __VA_ARGS__; Logger::log( AV_LOG_WARNING, os.str() ); }
65+
#define LOG_ERROR( ... ) { std::stringstream os; os << __VA_ARGS__; Logger::log( AV_LOG_ERROR, os.str() ); }
6666

6767
/// Logger class which contains static functions to use ffmpeg/libav log system
6868
class AvExport Logger
@@ -81,7 +81,7 @@ class AvExport Logger
8181
* @param msg: the message will be prefixed by '[avTranscoder - <level>]'
8282
* @param msg: the message will be suffixed by '\n'
8383
*/
84-
static void log( int level, const std::string& levelStr, const std::string& msg );
84+
static void log( int level, const std::string& msg );
8585
};
8686

8787
}

0 commit comments

Comments
 (0)