Merge pull request #2416 from cesanta/log

Add MG_ENABLE_CUSTOM_LOG
This commit is contained in:
Sergey Lyubka 2023-10-09 07:55:31 +01:00 committed by GitHub
commit fefe8b1c15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 0 deletions

View File

@ -3217,6 +3217,9 @@ void mg_log_set(int log_level) {
s_level = log_level;
}
#if MG_ENABLE_CUSTOM_LOG
// Let user define their own mg_log_prefix() and mg_log()
#else
bool mg_log_prefix(int level, const char *file, int line, const char *fname) {
if (level <= s_level) {
const char *p = strrchr(file, '/');
@ -3241,6 +3244,7 @@ void mg_log(const char *fmt, ...) {
va_end(ap);
logs("\r\n", 2);
}
#endif
static unsigned char nibble(unsigned c) {
return (unsigned char) (c < 10 ? c + '0' : c + 'W');

View File

@ -669,6 +669,10 @@ struct timeval {
#define MG_ENABLE_LOG 1
#endif
#ifndef MG_ENABLE_CUSTOM_LOG
#define MG_ENABLE_CUSTOM_LOG 0 // Let user define their own MG_LOG
#endif
#ifndef MG_ENABLE_TCPIP
#define MG_ENABLE_TCPIP 0 // Mongoose built-in network stack
#endif

View File

@ -4,6 +4,10 @@
#define MG_ENABLE_LOG 1
#endif
#ifndef MG_ENABLE_CUSTOM_LOG
#define MG_ENABLE_CUSTOM_LOG 0 // Let user define their own MG_LOG
#endif
#ifndef MG_ENABLE_TCPIP
#define MG_ENABLE_TCPIP 0 // Mongoose built-in network stack
#endif

View File

@ -26,6 +26,9 @@ void mg_log_set(int log_level) {
s_level = log_level;
}
#if MG_ENABLE_CUSTOM_LOG
// Let user define their own mg_log_prefix() and mg_log()
#else
bool mg_log_prefix(int level, const char *file, int line, const char *fname) {
if (level <= s_level) {
const char *p = strrchr(file, '/');
@ -50,6 +53,7 @@ void mg_log(const char *fmt, ...) {
va_end(ap);
logs("\r\n", 2);
}
#endif
static unsigned char nibble(unsigned c) {
return (unsigned char) (c < 10 ? c + '0' : c + 'W');