forked from coturn/coturn
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
170 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
logpath=../log | ||
|
||
log4cplus.appender.CONSOLE=log4cplus::ConsoleAppender | ||
log4cplus.appender.CONSOLE.Append=true | ||
log4cplus.appender.CONSOLE.layout=log4cplus::PatternLayout | ||
log4cplus.appender.CONSOLE.layout.ConversionPattern=[%t] %-5p %c - %m | ||
#log4cplus.appender.CONSOLE.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S,%Q} %l [%t] %-5p %c - %m | ||
|
||
log4cplus.appender.FILE=log4cplus::DailyRollingFileAppender | ||
log4cplus.appender.FILE.File=${logpath}/error.log | ||
log4cplus.appender.FILE.Schedule=HOURLY | ||
log4cplus.appender.FILE.Append=true | ||
log4cplus.appender.FILE.layout=log4cplus::PatternLayout | ||
log4cplus.appender.FILE.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S,%Q} [%t] %-5p %c - %m | ||
|
||
log4cplus.rootLogger=ALL, CONSOLE, FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include <log4cplus/logger.h> | ||
#include <log4cplus/clogger.h> | ||
#include <log4cplus/appender.h> | ||
#include <log4cplus/hierarchylocker.h> | ||
#include <log4cplus/hierarchy.h> | ||
#include <log4cplus/helpers/loglog.h> | ||
#include <log4cplus/configurator.h> | ||
#include <log4cplus/streams.h> | ||
#include <log4cplus/helpers/snprintf.h> | ||
#include <log4cplus/initializer.h> | ||
#include "ns_turn_utils.h" | ||
|
||
using namespace log4cplus; | ||
using namespace log4cplus::helpers; | ||
|
||
void* turn_log_init(){ | ||
int ret = -1; | ||
void* log = log4cplus_initialize(); | ||
const char* file = "../etc/log4cplus.conf"; | ||
FILE* pf = fopen(file, "a"); | ||
if(pf){ | ||
fclose(pf); | ||
ret = log4cplus_file_configure(file); | ||
} | ||
if(ret) | ||
log4cplus_basic_reconfigure(1); | ||
return log; | ||
} | ||
|
||
void turn_log_clean(void* log){ | ||
log4cplus_deinitialize(log); | ||
} | ||
|
||
int turn_log_set_conf_file(const char* file){ | ||
return log4cplus_file_reconfigure(file); | ||
} | ||
|
||
LogLevel turn_level_to_loglevel(TURN_LOG_LEVEL level) | ||
{ | ||
switch((int)level){ | ||
case TURN_LOG_LEVEL_DEBUG: | ||
return DEBUG_LOG_LEVEL; | ||
case TURN_LOG_LEVEL_INFO: | ||
return INFO_LOG_LEVEL; | ||
case TURN_LOG_LEVEL_WARNING: | ||
return WARN_LOG_LEVEL; | ||
case TURN_LOG_LEVEL_ERROR: | ||
return ERROR_LOG_LEVEL; | ||
} | ||
return DEBUG_LOG_LEVEL; | ||
} | ||
|
||
void turn_log_func_default(char *file, int line, char* function, char *category, TURN_LOG_LEVEL level, const char *msgfmt, ...) { | ||
int retval = -1; | ||
|
||
try | ||
{ | ||
Logger logger = category ? Logger::getInstance(category) : Logger::getRoot(); | ||
LogLevel ll = turn_level_to_loglevel(level); | ||
if( logger.isEnabledFor(ll) ) | ||
{ | ||
const tchar * msg = nullptr; | ||
snprintf_buf buf; | ||
std::va_list ap; | ||
|
||
do | ||
{ | ||
va_start(ap, msgfmt); | ||
retval = buf.print_va_list(msg, msgfmt, ap); | ||
va_end(ap); | ||
} | ||
while (retval == -1); | ||
|
||
logger.forcedLog(ll, msg, file, line, function); | ||
} | ||
|
||
retval = 0; | ||
} | ||
catch(std::exception const &) | ||
{ | ||
// Fall through. | ||
} | ||
|
||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"features": [ "openssl", "thread" ] | ||
}, | ||
"openssl", | ||
"log4cplus", | ||
"sqlite3", | ||
"libpq", | ||
"hiredis", | ||
|