Skip to content

Commit

Permalink
Add additional logging options
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlStraussberger committed Jun 13, 2024
1 parent fb914d9 commit ce861de
Show file tree
Hide file tree
Showing 17 changed files with 256 additions and 58 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Build support for libnpupnp 6.1.2
- Build: Add install scripts for alpine/docker
- Build: Add install scripts for OpenSuSE
- Build: add older debian
- Build: Allow build of ffmpegthumbnailer without ffmpeg
- Build: rework dependency handling
- Build: Scripts fail again with build
Expand All @@ -25,7 +26,9 @@
- docs: Update Arch Linux installs
- Docs: Update Ubuntu/Debian repo instructions
- Documentation: Update with new WebUI
- Extract command line argument handling to Runtime class
- FFMpeg: add custom logger
- Fix creation of mr_reg.xml
- Fix discovery
- Handle broken Systemd on some debian
- Import: Add option case sensitive tags
Expand Down
9 changes: 6 additions & 3 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## HEAD

This update brings a new design for the start page, better logging for TagLib and a new repository for ubuntu and debian getting rid of jfrog.
This update brings a new design for the start page, better logging and a new repository for ubuntu and debian getting rid of jfrog.

### NEW Features

Expand All @@ -12,9 +12,10 @@ This update brings a new design for the start page, better logging for TagLib an
- WebUI: New design for home page and login screen
- Allow metadata handler to be disabled, add charset support
- UPnP specification files (description.xml, cds.xml) now reflect client quirks
- Additional command line options for logging (--syslog and --rotatelog)
- TagLib messages are logged with gerbera now. They also show up with `debug-mode="taglib"`.
- Exiv2 messages are logged with gerbera now. They also show up with `debug-mode="exiv2"`.
- libexif messages are logged with gerbera now. They also show up with `debug-mode="exif"`.
- LibExiv2 messages are logged with gerbera now. They also show up with `debug-mode="exiv2"`.
- LibExif messages are logged with gerbera now. They also show up with `debug-mode="exif"`.
- ffmpeg messages are logged with gerbera now. They also show up with `debug-mode="ffmpeg"`.

### FIXES
Expand All @@ -23,12 +24,14 @@ This update brings a new design for the start page, better logging for TagLib an
- Build with ffmpegthumbnailer but without ffmpeg
- Changed repository for ubuntu and debian to https://pkg.gerbera.io/
- Autologout from UI
- Finally SIGHUP can be used to reload gerbera without restarting

### Code Improvements

- Rework of server mechanism for file and data requests
- Update versions of pupnp (1.14.19), npupnp (6.1.2), spdlog (1.14.1), taglib (2.0.1), ffmpegthumbnailer(2.2.2-60-g1b5a779)
- Allow building of libexif (up to v0.6.24-89-g87abeae)
- Refactoring of Inotify code and command line handling

## 2.1.0

Expand Down
8 changes: 8 additions & 0 deletions config/config2.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<xs:complexType>
<xs:all>
<xs:element ref="ui" minOccurs="0"/>
<xs:element ref="logging" minOccurs="0"/>
<xs:element ref="port" minOccurs="0"/>
<xs:element ref="name" minOccurs="0"/>

Expand Down Expand Up @@ -284,6 +285,13 @@
</xs:complexType>
</xs:element>

<xs:element name="logging">
<xs:complexType>
<xs:attribute name="rotate-file-size" type="xs:positiveInteger" default="5242880"/>
<xs:attribute name="rotate-file-count" type="xs:positiveInteger" default="10"/>
</xs:complexType>
</xs:element>

<xs:element name="accounts">
<xs:complexType>
<xs:sequence>
Expand Down
34 changes: 34 additions & 0 deletions doc/config-server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,40 @@ as a workaround for the TG100 bug which can only handle titles no longer than 10
A negative value will disable this feature, the minimum allowed value is "4" because three dots will be appended
to the string if it has been cut off to indicate that limiting took place.

.. _logging:

``logging``
~~~~~~~~~~~

.. code-block:: xml
<logging rotate-file-size="1000000" rotate-file-count="3"/>
* Optional

This section defines various logging settings.


**Attributes:**

::

rotate-file-size=...

* Optional
* Default: **5242880** (5 MB)

When using command line option ``--rotatelog`` this value defines the maximum size of the log file before rotating.

::

rotate-file-count=...

* Optional
* Default: **10**

When using command line option --rotatelog this value defines the number of files in the log rotation.

.. _ui:

``ui``
Expand Down
12 changes: 12 additions & 0 deletions doc/gerbera.1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ gerbera \- UPnP MediaServer
\fR] [
\fB-l|--logfile \fIlogfile\fB
\fR] [
\fB--rotatelog \fIlogfile\fB
\fR] [
\fB--syslog \fILOG\fB
\fR] [
\fB--add-file \fIfile\fB
\fR] [
\fB--set-option \fIopt=val\fB
Expand Down Expand Up @@ -137,6 +141,14 @@ with another use of --set-option.
Do not output log messages to stdout, but redirect everything to a specified
file.
.TP
\*(T<\fB\-l\fR\*(T>, \*(T<\fB\-\-rotatelog\fR\*(T>
Do not output log messages to stdout, but redirect everything to a specified
rotating file. It will rotate 10 files at 5MB.
.TP
\*(T<\fB\-l\fR\*(T>, \*(T<\fB\-\-syslog\fR\*(T>
Do not output log messages to stdout, but redirect everything to syslog. The optional
argument contains the syslog facility. If no argument is given LOG_USER is used.
.TP
\*(T<\fB\-D\fR\*(T>, \*(T<\fB\-\-debug\fR\*(T>
Enable debug log output.
.TP
Expand Down
4 changes: 2 additions & 2 deletions doc/run.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Daemon
::

--daemon or -d

Daemonize after startup. This option is useful if your system does not use Systemd or similar
mechanisms to start services. See also --user and --pidfile options, below.

Expand All @@ -232,7 +232,7 @@ User
::

--user or -u

After startup when started by user root try to change all UIDs and GIDs to those belonging to user USER.
Also supplementary GIDs will be set.

Expand Down
24 changes: 20 additions & 4 deletions doc/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,34 @@ Debugging
If you experience unexpected behaviour, you can run gerbera with ``--debug`` for
a full log output or ``--debug-mode`` for specific parts of gerbera.

Log To File
-----------
Logging
--------

Normally gerbera writes all messages to the system log (via standard output). Writing to your own log file
Normally gerbera writes all messages to standard output. Writing to your own log file
helps to search the logs for particular messages. Make sure you backup the file before restarting gerbera.

::

--logfile or -l
--logfile or -l FILE

Do not output log messages to stdout, but redirect everything to a specified file.

::

--rotatelog FILE

Do not output log messages to stdout, but redirect everything to a rotating list of files. The max size of each
log file can be set with config option ``server/logging/attribute::rotate-file-size``. The max count of log files
can be set with config option ``server/logging/attribute::rotate-file-count``. See :ref:`Logging <logging>`.

::

--syslog LOG

Do not output log messages to stdout, but redirect everything to syslog. The optional
argument contains the syslog facility. If no argument is given LOG_USER is used. The following values for ``LOG``
are supported ``USER`` (default), ``LOCAL0`` to ``LOCAL7``.

Debug Output
------------

Expand Down
2 changes: 1 addition & 1 deletion scripts/launchd/gerbera.io.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string>/usr/bin/gerbera</string>
<string>-c</string>
<string>/etc/gerbera/config.xml</string>
<string>-l</string>
<string>--rotatelog</string>
<string>/var/log/gerbera.log</string>
</array>
<key>RunAtLoad</key>
Expand Down
2 changes: 1 addition & 1 deletion scripts/systemd/gerbera.service.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Wants=${SYSTEMD_WANTS_TARGET}
Type=simple
User=gerbera
Group=gerbera
ExecStart=${CMAKE_INSTALL_PREFIX}/bin/gerbera -c /etc/gerbera/config.xml
ExecStart=${CMAKE_INSTALL_PREFIX}/bin/gerbera -c /etc/gerbera/config.xml --syslog
Restart=on-failure
RestartSec=5

Expand Down
4 changes: 3 additions & 1 deletion src/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,10 @@ enum config_option_t {
CFG_SERVER_DYNAMIC_CONTENT_LIST,
CFG_IMPORT_RESOURCES_ORDER,
#ifdef GRBDEBUG
CFG_SERVER_DEBUG_MODE,
CFG_SERVER_LOG_DEBUG_MODE,
#endif
CFG_SERVER_LOG_ROTATE_SIZE,
CFG_SERVER_LOG_ROTATE_COUNT,

CFG_MAX,

Expand Down
8 changes: 7 additions & 1 deletion src/config/config_definition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,16 @@ const std::vector<std::shared_ptr<ConfigSetup>> ConfigDefinition::complexOptions
YES),

#ifdef GRBDEBUG
std::make_shared<ConfigIntSetup>(CFG_SERVER_DEBUG_MODE,
std::make_shared<ConfigIntSetup>(CFG_SERVER_LOG_DEBUG_MODE,
"/server/attribute::debug-mode", "config-server.html#debug-mode",
0, GrbLogger::makeFacility, GrbLogger::printFacility),
#endif
std::make_shared<ConfigUIntSetup>(CFG_SERVER_LOG_ROTATE_SIZE,
"/server/logging/attribute::rotate-file-size", "config-server.html#logging",
1024 * 1024 * 5),
std::make_shared<ConfigUIntSetup>(CFG_SERVER_LOG_ROTATE_COUNT,
"/server/logging/attribute::rotate-file-count", "config-server.html#logging",
10),

std::make_shared<ConfigClientSetup>(CFG_CLIENTS_LIST,
"/clients", "config-clients.html#clients"),
Expand Down
2 changes: 1 addition & 1 deletion src/config/config_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void ConfigGenerator::generateServer(const fs::path& userHome, const fs::path& c
{ CFG_UPNP_TITLE_NAMESPACES, false },
{ CFG_UPNP_CAPTION_COUNT, false },
#ifdef GRBDEBUG
{ CFG_SERVER_DEBUG_MODE, false },
{ CFG_SERVER_LOG_DEBUG_MODE, false },
#endif
};

Expand Down
Loading

0 comments on commit ce861de

Please sign in to comment.