mod_tile 0.9.1
Renders map tiles with Mapnik and serves them using Apache HTTP Server
Loading...
Searching...
No Matches
g_logger.c File Reference
#include <glib.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>

Macros

#define _GNU_SOURCE   1
#define G_LOG_USE_STRUCTURED   1

Functions

const char * g_logger_level_name (int log_level)
 Convert a GLib log level flag into a human-readable uppercase label.
void g_logger (int log_level, const char *format,...)
 Format and route a log message to stdout/stderr, systemd-journald, or syslog.

Variables

int foreground = 0
 Execution mode flag indicating whether the daemon runs in the foreground.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE   1

◆ G_LOG_USE_STRUCTURED

#define G_LOG_USE_STRUCTURED   1

Function Documentation

◆ g_logger()

void g_logger ( int log_level,
const char * format,
... )

Format and route a log message to stdout/stderr, systemd-journald, or syslog.

Selects the logging backend automatically based on runtime environment:

  1. Standard streams (stdout/stderr) when foreground == 1.
  2. systemd-journald when stderr is connected to the journal socket.
  3. Traditional syslog (up to LOG_INFO severity) as a fallback.

Unlike default GLib fatal error handling, G_LOG_LEVEL_ERROR messages are logged without terminating the process, and G_LOG_LEVEL_INFO messages are emitted unconditionally without requiring G_MESSAGES_DEBUG.

Parameters
log_levelGLib log severity level (GLogLevelFlags).
formatprintf-style format string.
...Variadic arguments corresponding to format.

◆ g_logger_level_name()

const char * g_logger_level_name ( int log_level)

Convert a GLib log level flag into a human-readable uppercase label.

Parameters
log_levelGLib log level (e.g., G_LOG_LEVEL_ERROR, G_LOG_LEVEL_INFO).
Returns
Constant string representation of the log level, or "UNKNOWN" if the level is not recognized.

Variable Documentation

◆ foreground

int foreground = 0

Execution mode flag indicating whether the daemon runs in the foreground.

When set to 1, log output is directed to standard streams (stdout/stderr) via GLib writers rather than systemd-journald or syslog.