Skip to content

Commit f1ff3cc

Browse files
author
commit-queue@webkit.org
committed
.:
Enable logging under non-systemd linux distros https://bugs.webkit.org/show_bug.cgi?id=232080 Patch by Pablo Correa Gómez <ablocorrea@hotmail.com> on 2021-10-22 Reviewed by Michael Catanzaro. * Source/cmake/FindJournald.cmake: Renamed from Source/cmake/FindSystemd.cmake. * Source/cmake/OptionsGTK.cmake: Replace USE_SYSTEMD for ENABLE_JOURNALD_LOG * Source/cmake/OptionsWPE.cmake: Replace USE_SYSTEMD for ENABLE_JOURNALD_LOG Source/WTF: Enable logging in under non-systemd linux distros https://bugs.webkit.org/show_bug.cgi?id=232080 Patch by Pablo Correa Gómez <ablocorrea@hotmail.com> on 2021-10-22 Reviewed by Michael Catanzaro. * wtf/Assertions.h: Rename USE(JOURNALD) to ENABLE(JOURNALD_LOG) * wtf/Logger.h: (WTF::Logger::willLog const): Rename USE(JOURNALD) to ENABLE(JOURNALD_LOG) * wtf/PlatformGTK.cmake: Use renamed Journald library * wtf/PlatformWPE.cmake: Use renamed Journald library Canonical link: https://commits.webkit.org/243393@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284673 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 603c81f commit f1ff3cc

File tree

10 files changed

+94
-60
lines changed

10 files changed

+94
-60
lines changed

ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2021-10-22 Pablo Correa Gómez <ablocorrea@hotmail.com>
2+
3+
Enable logging under non-systemd linux distros
4+
https://bugs.webkit.org/show_bug.cgi?id=232080
5+
6+
Reviewed by Michael Catanzaro.
7+
8+
* Source/cmake/FindJournald.cmake: Renamed from Source/cmake/FindSystemd.cmake.
9+
* Source/cmake/OptionsGTK.cmake: Replace USE_SYSTEMD for
10+
ENABLE_JOURNALD_LOG
11+
* Source/cmake/OptionsWPE.cmake: Replace USE_SYSTEMD for
12+
ENABLE_JOURNALD_LOG
13+
114
2021-10-21 Eric Carlson <eric.carlson@apple.com>
215

316
Add GitHub name to contributors.json

Source/WTF/ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2021-10-22 Pablo Correa Gómez <ablocorrea@hotmail.com>
2+
3+
Enable logging in under non-systemd linux distros
4+
https://bugs.webkit.org/show_bug.cgi?id=232080
5+
6+
Reviewed by Michael Catanzaro.
7+
8+
* wtf/Assertions.h: Rename USE(JOURNALD) to ENABLE(JOURNALD_LOG)
9+
* wtf/Logger.h:
10+
(WTF::Logger::willLog const): Rename USE(JOURNALD) to
11+
ENABLE(JOURNALD_LOG)
12+
* wtf/PlatformGTK.cmake: Use renamed Journald library
13+
* wtf/PlatformWPE.cmake: Use renamed Journald library
14+
115
2021-10-21 Aditya Keerthi <akeerthi@apple.com>
216

317
[Cocoa] Enable accent-color by default

Source/WTF/wtf/Assertions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ void WTFReleaseLogStackTrace(WTFLogChannel* channel)
609609
out.printf("%-3d %p %s", frameNumber, stackFrame, demangled->mangledName());
610610
else
611611
out.printf("%-3d %p", frameNumber, stackFrame);
612-
#if USE(JOURNALD)
612+
#if ENABLE(JOURNALD_LOG)
613613
sd_journal_send("WEBKIT_SUBSYSTEM=%s", channel->subsystem, "WEBKIT_CHANNEL=%s", channel->name, "MESSAGE=%s", out.toCString().data(), nullptr);
614614
#else
615615
fprintf(stderr, "[%s:%s:-] %s\n", channel->subsystem, channel->name, out.toCString().data());

Source/WTF/wtf/Assertions.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#include <os/log.h>
5252
#endif
5353

54-
#if USE(JOURNALD)
54+
#if ENABLE(JOURNALD_LOG)
5555
#define SD_JOURNAL_SUPPRESS_LOCATION
5656
#include <systemd/sd-journal.h>
5757
#endif
@@ -98,11 +98,11 @@ extern "C" void _ReadWriteBarrier(void);
9898
#if ENABLE(RELEASE_LOG)
9999
#define RELEASE_LOG_DISABLED 0
100100
#else
101-
#define RELEASE_LOG_DISABLED !(USE(OS_LOG) || USE(JOURNALD))
101+
#define RELEASE_LOG_DISABLED !(USE(OS_LOG) || ENABLE(JOURNALD_LOG))
102102
#endif
103103

104104
#ifndef VERBOSE_RELEASE_LOG
105-
#define VERBOSE_RELEASE_LOG USE(JOURNALD)
105+
#define VERBOSE_RELEASE_LOG ENABLE(JOURNALD_LOG)
106106
#endif
107107

108108
#if COMPILER(GCC_COMPATIBLE)
@@ -565,7 +565,7 @@ constexpr bool assertionFailureDueToUnreachableCode = false;
565565
os_log(LOG_CHANNEL(channel).osLogChannel, __VA_ARGS__); \
566566
} while (0)
567567

568-
#elif USE(JOURNALD)
568+
#elif ENABLE(JOURNALD_LOG)
569569

570570
#define PUBLIC_LOG_STRING "s"
571571
#define PRIVATE_LOG_STRING "s"

Source/WTF/wtf/Logger.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <wtf/ThreadSafeRefCounted.h>
3131
#include <wtf/text/StringBuilder.h>
3232

33-
#if USE(JOURNALD)
33+
#if ENABLE(JOURNALD_LOG)
3434
#define SD_JOURNAL_SUPPRESS_LOCATION
3535
#include <systemd/sd-journal.h>
3636
#endif
@@ -241,7 +241,7 @@ class Logger : public ThreadSafeRefCounted<Logger> {
241241
if (!m_enabled)
242242
return false;
243243

244-
#if USE(SYSTEMD)
244+
#if ENABLE(JOURNALD_LOG)
245245
if (channel.state == WTFLogChannelState::Off)
246246
return false;
247247
#endif
@@ -314,7 +314,7 @@ class Logger : public ThreadSafeRefCounted<Logger> {
314314
WTFLog(&channel, "%s", logMessage.utf8().data());
315315
#elif USE(OS_LOG)
316316
os_log(channel.osLogChannel, "%{public}s", logMessage.utf8().data());
317-
#elif USE(JOURNALD)
317+
#elif ENABLE(JOURNALD_LOG)
318318
sd_journal_send("WEBKIT_SUBSYSTEM=%s", channel.subsystem, "WEBKIT_CHANNEL=%s", channel.name, "MESSAGE=%s", logMessage.utf8().data(), nullptr);
319319
#else
320320
fprintf(stderr, "[%s:%s:-] %s\n", channel.subsystem, channel.name, logMessage.utf8().data());
@@ -343,7 +343,7 @@ class Logger : public ThreadSafeRefCounted<Logger> {
343343
UNUSED_PARAM(file);
344344
UNUSED_PARAM(line);
345345
UNUSED_PARAM(function);
346-
#elif USE(JOURNALD)
346+
#elif ENABLE(JOURNALD_LOG)
347347
auto fileString = makeString("CODE_FILE=", file);
348348
auto lineString = makeString("CODE_LINE=", line);
349349
sd_journal_send_with_location(fileString.utf8().data(), lineString.utf8().data(), function, "WEBKIT_SUBSYSTEM=%s", channel.subsystem, "WEBKIT_CHANNEL=%s", channel.name, "MESSAGE=%s", logMessage.utf8().data(), nullptr);

Source/WTF/wtf/PlatformGTK.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ list(APPEND WTF_LIBRARIES
7979
ZLIB::ZLIB
8080
)
8181

82-
if (Systemd_FOUND)
83-
list(APPEND WTF_LIBRARIES Systemd::Systemd)
82+
if (Journald_FOUND)
83+
list(APPEND WTF_LIBRARIES Journald::Journald)
8484
endif ()
8585

8686
list(APPEND WTF_SYSTEM_INCLUDE_DIRECTORIES

Source/WTF/wtf/PlatformWPE.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ list(APPEND WTF_LIBRARIES
5252
ZLIB::ZLIB
5353
)
5454

55-
if (Systemd_FOUND)
56-
list(APPEND WTF_LIBRARIES Systemd::Systemd)
55+
if (Journald_FOUND)
56+
list(APPEND WTF_LIBRARIES Journald::Journald)
5757
endif ()
5858

5959
list(APPEND WTF_SYSTEM_INCLUDE_DIRECTORIES
Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,71 +22,78 @@
2222
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2323

2424
#[=======================================================================[.rst:
25-
FindSystemd
25+
FindJournald
2626
-----------
2727
28-
Find Systemd headers and libraries.
28+
Find Journald-compatible headers and libraries.
2929
3030
Imported Targets
3131
^^^^^^^^^^^^^^^^
3232
33-
``Systemd::Systemd``
34-
The Systemd library, if found.
33+
``Journald::Journald``
34+
The library where Journald symbols reside, if found.
3535
3636
Result Variables
3737
^^^^^^^^^^^^^^^^
3838
3939
This will define the following variables in your project:
4040
41-
``Systemd_FOUND``
42-
true if (the requested version of) Systemd is available.
43-
``Systemd_VERSION``
44-
the version of Systemd.
45-
``Systemd_LIBRARIES``
46-
the libraries to link against to use Systemd.
47-
``Systemd_INCLUDE_DIRS``
48-
where to find the Systemd headers.
49-
``Systemd_COMPILE_OPTIONS``
41+
``Journald_FOUND``
42+
true if (the requested version of) Journald is available.
43+
``Journald_VERSION``
44+
the version of the library where Journald symbols reside.
45+
``Journald_LIBRARIES``
46+
the libraries to link against to use Journald.
47+
``Journald_INCLUDE_DIRS``
48+
where to find the Journald headers.
49+
``Journald_COMPILE_OPTIONS``
5050
this should be passed to target_compile_options(), if the
5151
target is not used for linking
5252
5353
#]=======================================================================]
54-
5554
find_package(PkgConfig QUIET)
5655

56+
# libelogind provides compatible pc and header files
5757
pkg_check_modules(PC_SYSTEMD QUIET libsystemd)
58-
set(Systemd_COMPILE_OPTIONS ${PC_SYSTEMD_CFLAGS_OTHER})
59-
set(Systemd_VERSION ${PC_SYSTEMD_VERSION})
58+
set(Journald_COMPILE_OPTIONS ${PC_SYSTEMD_CFLAGS_OTHER})
59+
set(Journald_VERSION ${PC_SYSTEMD_VERSION})
6060

61-
find_path(Systemd_INCLUDE_DIR
61+
find_path(Journald_INCLUDE_DIR
6262
NAMES systemd/sd-journal.h
6363
HINTS ${PC_SYSTEMD_INCLUDEDIR} ${PC_SYSTEMD_INCLUDE_DIRS}
6464
)
6565

66-
find_library(Systemd_LIBRARY
67-
NAMES ${Systemd_NAMES} systemd
66+
find_library(Journald_LIBRARY
67+
NAMES ${Journald_NAMES} systemd
6868
HINTS ${PC_SYSTEMD_LIBDIR} ${PC_SYSTEMD_LIBRARY_DIRS}
6969
)
7070

71+
if (NOT Journald_LIBRARY)
72+
find_library(Journald_LIBRARY
73+
NAMES ${Journald_NAMES} elogind
74+
HINTS ${PC_SYSTEMD_LIBDIR} ${PC_SYSTEMD_LIBRARY_DIRS}
75+
)
76+
endif ()
77+
7178
include(FindPackageHandleStandardArgs)
72-
find_package_handle_standard_args(Systemd
73-
FOUND_VAR Systemd_FOUND
74-
REQUIRED_VARS Systemd_LIBRARY Systemd_INCLUDE_DIR
75-
VERSION_VAR Systemd_VERSION
79+
find_package_handle_standard_args(Journald
80+
FOUND_VAR Journald_FOUND
81+
REQUIRED_VARS Journald_LIBRARY Journald_INCLUDE_DIR
82+
VERSION_VAR Journald_VERSION
7683
)
7784

78-
if (Systemd_LIBRARY AND NOT TARGET Systemd::Systemd)
79-
add_library(Systemd::Systemd UNKNOWN IMPORTED GLOBAL)
80-
set_target_properties(Systemd::Systemd PROPERTIES
81-
IMPORTED_LOCATION "${Systemd_LIBRARY}"
82-
INTERFACE_COMPILE_OPTIONS "${Systemd_COMPILE_OPTIONS}"
83-
INTERFACE_INCLUDE_DIRECTORIES "${Systemd_INCLUDE_DIR}"
85+
if (Journald_LIBRARY AND NOT TARGET Journald::Journald)
86+
add_library(Journald::Journald UNKNOWN IMPORTED GLOBAL)
87+
set_target_properties(Journald::Journald PROPERTIES
88+
IMPORTED_LOCATION "${Journald_LIBRARY}"
89+
INTERFACE_COMPILE_OPTIONS "${Journald_COMPILE_OPTIONS}"
90+
INTERFACE_INCLUDE_DIRECTORIES "${Journald_INCLUDE_DIR}"
8491
)
8592
endif ()
8693

87-
mark_as_advanced(Systemd_INCLUDE_DIR Systemd_LIBRARY)
94+
mark_as_advanced(Journald_INCLUDE_DIR Journald_LIBRARY)
8895

89-
if (Systemd_FOUND)
90-
set(Systemd_LIBRARIES ${Systemd_LIBRARY})
91-
set(Systemd_INCLUDE_DIRS ${Systemd_INCLUDE_DIR})
96+
if (Journald_FOUND)
97+
set(Journald_LIBRARIES ${Journald_LIBRARY})
98+
set(Journald_INCLUDE_DIRS ${Journald_INCLUDE_DIR})
9299
endif ()

Source/cmake/OptionsGTK.cmake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ endif ()
5656
WEBKIT_OPTION_DEFINE(ENABLE_GLES2 "Whether to enable OpenGL ES 2.0." PUBLIC ${ENABLE_GLES2_DEFAULT})
5757
WEBKIT_OPTION_DEFINE(ENABLE_GTKDOC "Whether or not to use generate gtkdoc." PUBLIC OFF)
5858
WEBKIT_OPTION_DEFINE(ENABLE_INTROSPECTION "Whether to enable GObject introspection." PUBLIC ON)
59+
WEBKIT_OPTION_DEFINE(ENABLE_JOURNALD_LOG "Whether to enable journald logging" PUBLIC ON)
5960
WEBKIT_OPTION_DEFINE(ENABLE_QUARTZ_TARGET "Whether to enable support for the Quartz windowing target." PUBLIC ON)
6061
WEBKIT_OPTION_DEFINE(ENABLE_WAYLAND_TARGET "Whether to enable support for the Wayland windowing target." PUBLIC ON)
6162
WEBKIT_OPTION_DEFINE(ENABLE_X11_TARGET "Whether to enable support for the X11 windowing target." PUBLIC ON)
@@ -68,7 +69,6 @@ WEBKIT_OPTION_DEFINE(USE_LIBSECRET "Whether to enable the persistent credential
6869
WEBKIT_OPTION_DEFINE(USE_OPENGL_OR_ES "Whether to use OpenGL or ES." PUBLIC ON)
6970
WEBKIT_OPTION_DEFINE(USE_OPENJPEG "Whether to enable support for JPEG2000 images." PUBLIC ON)
7071
WEBKIT_OPTION_DEFINE(USE_SOUP2 "Whether to enable usage of Soup 2 instead of Soup 3." PUBLIC OFF)
71-
WEBKIT_OPTION_DEFINE(USE_SYSTEMD "Whether to enable journald logging" PUBLIC ON)
7272
WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON)
7373
WEBKIT_OPTION_DEFINE(USE_WPE_RENDERER "Whether to enable WPE rendering" PUBLIC ON)
7474

@@ -455,13 +455,13 @@ if (USE_AVIF)
455455
endif ()
456456
endif ()
457457

458-
if (USE_SYSTEMD)
459-
find_package(Systemd)
460-
if (Systemd_FOUND)
461-
message(STATUS "Release logs will be sent to the Systemd journal")
462-
SET_AND_EXPOSE_TO_BUILD(USE_JOURNALD TRUE)
458+
if (ENABLE_JOURNALD_LOG)
459+
find_package(Journald)
460+
if (Journald_FOUND)
461+
message(STATUS "Release logs will be sent using journald logging interface")
462+
SET_AND_EXPOSE_TO_BUILD(ENABLE_JOURNALD_LOG TRUE)
463463
else ()
464-
message(FATAL_ERROR "libsystemd is needed for USE_SYSTEMD")
464+
message(FATAL_ERROR "libsystemd or libelogind are needed for ENABLE_JOURNALD_LOG")
465465
endif ()
466466
endif ()
467467

Source/cmake/OptionsWPE.cmake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBXR PRIVATE ${ENABLE_EXPERIMENTAL_FEAT
7373
# there is a strong reason we should support changing the value of the option,
7474
# and the option is not relevant to any other WebKit ports.
7575
WEBKIT_OPTION_DEFINE(ENABLE_GTKDOC "Whether or not to use generate gtkdoc." PUBLIC OFF)
76+
WEBKIT_OPTION_DEFINE(ENABLE_JOURNALD_LOG "Whether to enable journald logging" PUBLIC ON)
7677
WEBKIT_OPTION_DEFINE(ENABLE_WPE_QT_API "Whether to enable support for the Qt5/QML plugin" PUBLIC ${ENABLE_DEVELOPER_MODE})
7778
WEBKIT_OPTION_DEFINE(USE_AVIF "Whether to enable support for AVIF images." PUBLIC ${ENABLE_EXPERIMENTAL_FEATURES})
7879
WEBKIT_OPTION_DEFINE(USE_LCMS "Whether to enable support for image color management using libcms2." PUBLIC ON)
7980
WEBKIT_OPTION_DEFINE(USE_OPENJPEG "Whether to enable support for JPEG2000 images." PUBLIC ON)
8081
WEBKIT_OPTION_DEFINE(USE_SOUP2 "Whether to enable usage of Soup 2 instead of Soup 3." PUBLIC OFF)
81-
WEBKIT_OPTION_DEFINE(USE_SYSTEMD "Whether to enable journald logging" PUBLIC ON)
8282
WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON)
8383

8484
# Private options specific to the WPE port.
@@ -232,13 +232,13 @@ if (USE_AVIF)
232232
endif ()
233233
endif ()
234234

235-
if (USE_SYSTEMD)
236-
find_package(Systemd)
237-
if (Systemd_FOUND)
238-
message(STATUS "Release logs will be sent to the Systemd journal")
239-
SET_AND_EXPOSE_TO_BUILD(USE_JOURNALD TRUE)
235+
if (ENABLE_JOURNALD_LOG)
236+
find_package(Journald)
237+
if (Journald_FOUND)
238+
message(STATUS "Release logs will be sent using journald logging interface")
239+
SET_AND_EXPOSE_TO_BUILD(ENABLE_JOURNALD_LOG TRUE)
240240
else ()
241-
message(FATAL_ERROR "libsystemd is needed for USE_SYSTEMD")
241+
message(FATAL_ERROR "libsystemd or libelogind are needed for ENABLE_JOURNALD_LOG")
242242
endif ()
243243
endif ()
244244

0 commit comments

Comments
 (0)