summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-05-22 18:38:25 +0200
committerMax Kellermann <max@musicpd.org>2019-05-23 12:17:59 +0200
commite0d5d8810452265fe2e4d95eefb5585eb65f9ce5 (patch)
tree5405f3593158c9e425be4c7cbdd41b44ca78a0e8
parent585a74548485787525bb8b9c921b97ccced2f957 (diff)
Log: make LogLevel the first parameter
Prepare for templated functions.
-rw-r--r--src/Log.cxx22
-rw-r--r--src/Log.hxx16
-rw-r--r--src/LogBackend.cxx4
-rw-r--r--src/LogBackend.hxx2
-rw-r--r--src/LogV.hxx4
-rw-r--r--src/decoder/plugins/FluidsynthDecoderPlugin.cxx4
-rw-r--r--src/lib/ffmpeg/LogCallback.cxx2
-rw-r--r--src/system/FatalError.cxx2
-rw-r--r--test/test_translate_song.cxx2
9 files changed, 29 insertions, 29 deletions
diff --git a/src/Log.cxx b/src/Log.cxx
index 6e47512c4..befe238c9 100644
--- a/src/Log.cxx
+++ b/src/Log.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2018 The Music Player Daemon Project
+ * Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -28,20 +28,20 @@
static constexpr Domain exception_domain("exception");
void
-LogFormatV(const Domain &domain, LogLevel level,
+LogFormatV(LogLevel level, const Domain &domain,
const char *fmt, va_list ap) noexcept
{
char msg[1024];
vsnprintf(msg, sizeof(msg), fmt, ap);
- Log(domain, level, msg);
+ Log(level, domain, msg);
}
void
-LogFormat(const Domain &domain, LogLevel level, const char *fmt, ...) noexcept
+LogFormat(LogLevel level, const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
va_start(ap, fmt);
- LogFormatV(domain, level, fmt, ap);
+ LogFormatV(level, domain, fmt, ap);
va_end(ap);
}
@@ -50,7 +50,7 @@ FormatDebug(const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
va_start(ap, fmt);
- LogFormatV(domain, LogLevel::DEBUG, fmt, ap);
+ LogFormatV(LogLevel::DEBUG, domain, fmt, ap);
va_end(ap);
}
@@ -59,7 +59,7 @@ FormatInfo(const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
va_start(ap, fmt);
- LogFormatV(domain, LogLevel::INFO, fmt, ap);
+ LogFormatV(LogLevel::INFO, domain, fmt, ap);
va_end(ap);
}
@@ -68,7 +68,7 @@ FormatDefault(const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
va_start(ap, fmt);
- LogFormatV(domain, LogLevel::DEFAULT, fmt, ap);
+ LogFormatV(LogLevel::DEFAULT, domain, fmt, ap);
va_end(ap);
}
@@ -77,7 +77,7 @@ FormatWarning(const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
va_start(ap, fmt);
- LogFormatV(domain, LogLevel::WARNING, fmt, ap);
+ LogFormatV(LogLevel::WARNING, domain, fmt, ap);
va_end(ap);
}
@@ -86,7 +86,7 @@ FormatError(const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
va_start(ap, fmt);
- LogFormatV(domain, LogLevel::ERROR, fmt, ap);
+ LogFormatV(LogLevel::ERROR, domain, fmt, ap);
va_end(ap);
}
@@ -142,7 +142,7 @@ FormatError(const std::exception_ptr &ep, const char *fmt, ...) noexcept
void
LogErrno(const Domain &domain, int e, const char *msg) noexcept
{
- LogFormat(domain, LogLevel::ERROR, "%s: %s", msg, strerror(e));
+ LogFormat(LogLevel::ERROR, domain, "%s: %s", msg, strerror(e));
}
void
diff --git a/src/Log.hxx b/src/Log.hxx
index 2e8c0c6ee..7454d96ea 100644
--- a/src/Log.hxx
+++ b/src/Log.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2018 The Music Player Daemon Project
+ * Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -28,16 +28,16 @@
class Domain;
void
-Log(const Domain &domain, LogLevel level, const char *msg) noexcept;
+Log(LogLevel level, const Domain &domain, const char *msg) noexcept;
gcc_printf(3,4)
void
-LogFormat(const Domain &domain, LogLevel level, const char *fmt, ...) noexcept;
+LogFormat(LogLevel level, const Domain &domain, const char *fmt, ...) noexcept;
static inline void
LogDebug(const Domain &domain, const char *msg) noexcept
{
- Log(domain, LogLevel::DEBUG, msg);
+ Log(LogLevel::DEBUG, domain, msg);
}
gcc_printf(2,3)
@@ -47,7 +47,7 @@ FormatDebug(const Domain &domain, const char *fmt, ...) noexcept;
static inline void
LogInfo(const Domain &domain, const char *msg) noexcept
{
- Log(domain, LogLevel::INFO, msg);
+ Log(LogLevel::INFO, domain, msg);
}
gcc_printf(2,3)
@@ -57,7 +57,7 @@ FormatInfo(const Domain &domain, const char *fmt, ...) noexcept;
static inline void
LogDefault(const Domain &domain, const char *msg) noexcept
{
- Log(domain, LogLevel::DEFAULT, msg);
+ Log(LogLevel::DEFAULT, domain, msg);
}
gcc_printf(2,3)
@@ -67,7 +67,7 @@ FormatDefault(const Domain &domain, const char *fmt, ...) noexcept;
static inline void
LogWarning(const Domain &domain, const char *msg) noexcept
{
- Log(domain, LogLevel::WARNING, msg);
+ Log(LogLevel::WARNING, domain, msg);
}
gcc_printf(2,3)
@@ -77,7 +77,7 @@ FormatWarning(const Domain &domain, const char *fmt, ...) noexcept;
static inline void
LogError(const Domain &domain, const char *msg) noexcept
{
- Log(domain, LogLevel::ERROR, msg);
+ Log(LogLevel::ERROR, domain, msg);
}
void
diff --git a/src/LogBackend.cxx b/src/LogBackend.cxx
index 874da1af0..f7760ee23 100644
--- a/src/LogBackend.cxx
+++ b/src/LogBackend.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2018 The Music Player Daemon Project
+ * Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -176,7 +176,7 @@ FileLog(const Domain &domain, const char *message) noexcept
#endif /* !ANDROID */
void
-Log(const Domain &domain, LogLevel level, const char *msg) noexcept
+Log(LogLevel level, const Domain &domain, const char *msg) noexcept
{
#ifdef ANDROID
__android_log_print(ToAndroidLogLevel(level), "MPD",
diff --git a/src/LogBackend.hxx b/src/LogBackend.hxx
index 76d7b1910..b90354755 100644
--- a/src/LogBackend.hxx
+++ b/src/LogBackend.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2018 The Music Player Daemon Project
+ * Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/LogV.hxx b/src/LogV.hxx
index 23e27d931..7e55d3d24 100644
--- a/src/LogV.hxx
+++ b/src/LogV.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2018 The Music Player Daemon Project
+ * Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -25,7 +25,7 @@
#include <stdarg.h>
void
-LogFormatV(const Domain &domain, LogLevel level,
+LogFormatV(LogLevel level, const Domain &domain,
const char *fmt, va_list ap) noexcept;
#endif /* LOG_H */
diff --git a/src/decoder/plugins/FluidsynthDecoderPlugin.cxx b/src/decoder/plugins/FluidsynthDecoderPlugin.cxx
index 9002da363..aa58ea3a2 100644
--- a/src/decoder/plugins/FluidsynthDecoderPlugin.cxx
+++ b/src/decoder/plugins/FluidsynthDecoderPlugin.cxx
@@ -70,8 +70,8 @@ fluidsynth_mpd_log_function(int level,
char *message,
void *)
{
- Log(fluidsynth_domain,
- fluidsynth_level_to_mpd(fluid_log_level(level)),
+ Log(fluidsynth_level_to_mpd(fluid_log_level(level)),
+ fluidsynth_domain,
message);
}
diff --git a/src/lib/ffmpeg/LogCallback.cxx b/src/lib/ffmpeg/LogCallback.cxx
index f236b0eea..0dcdb5e6c 100644
--- a/src/lib/ffmpeg/LogCallback.cxx
+++ b/src/lib/ffmpeg/LogCallback.cxx
@@ -62,6 +62,6 @@ FfmpegLogCallback(gcc_unused void *ptr, int level, const char *fmt, va_list vl)
ffmpeg_domain.GetName(),
cls->item_name(ptr));
const Domain d(domain);
- LogFormatV(d, FfmpegImportLogLevel(level), fmt, vl);
+ LogFormatV(FfmpegImportLogLevel(level), d, fmt, vl);
}
}
diff --git a/src/system/FatalError.cxx b/src/system/FatalError.cxx
index b846dc830..dc056ca3c 100644
--- a/src/system/FatalError.cxx
+++ b/src/system/FatalError.cxx
@@ -54,7 +54,7 @@ FormatFatalError(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- LogFormatV(fatal_error_domain, LogLevel::ERROR, fmt, ap);
+ LogFormatV(LogLevel::ERROR, fatal_error_domain, fmt, ap);
va_end(ap);
Abort();
diff --git a/test/test_translate_song.cxx b/test/test_translate_song.cxx
index 914405e2e..abd2d0cd6 100644
--- a/test/test_translate_song.cxx
+++ b/test/test_translate_song.cxx
@@ -25,7 +25,7 @@
#include <stdio.h>
void
-Log(const Domain &domain, gcc_unused LogLevel level, const char *msg) noexcept
+Log(LogLevel, const Domain &domain, const char *msg) noexcept
{
fprintf(stderr, "[%s] %s\n", domain.GetName(), msg);
}