---
name: "dlog.h"
section: "3"
platform: "linux"
package: "libdaemon-doc"
version: "0.14-7.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/dlog.h"
---

# dlog.h(3)

Contains a robust API for logging messages.

## NAME

dlog.h - Contains a robust API for logging messages.

## SYNOPSIS

`#include <syslog.h>`\
 `#include <stdarg.h>`\

### Macros

\#define **DAEMON\_GCC\_PRINTF\_ATTR**(a,  b)\
 A macro for making use of GCCs printf compilation warnings.  #define **DAEMON\_LOGV\_AVAILABLE**   1\
 This variable is defined to 1 iff **daemon\_logv()** is supported.  #define **DAEMON\_SET\_VERBOSITY\_AVAILABLE**   1\
 This variable is defined to 1 iff **daemon\_set\_verbosity()** is available.

### Enumerations

enum **daemon\_log\_flags** { **DAEMON\_LOG\_SYSLOG** = 1, **DAEMON\_LOG\_STDERR** = 2, **DAEMON\_LOG\_STDOUT** = 4, **DAEMON\_LOG\_AUTO** = 8 }\
 Specifies where to send the log messages to.

### Functions

void **daemon\_log** (int prio, const char \*t,...) **DAEMON\_GCC\_PRINTF\_ATTR**(2\
 Log a message using printf format strings using the specified syslog priority.  void **daemon\_logv** (int prio, const char \*t, va\_list ap)\
 Same as **daemon\_log()**, but without variadic arguments.  char \* **daemon\_ident\_from\_argv0** (char \*argv0)\
 Return a sensible syslog identification for daemon\_log\_ident generated from argv\[0\].  void **daemon\_set\_verbosity** (int verbosity\_prio)\
 Setter for the verbosity level of standard output.

### Variables

enum **daemon\_log\_flags** **daemon\_log\_use**\
 This variable is used to specify the log target(s) to use.  const char \* **daemon\_log\_ident**\
 Specifies the syslog identification, use **daemon\_ident\_from\_argv0()** to set this to a sensible value or generate your own.

## Detailed Description

Contains a robust API for logging messages.

Definition in file **dlog.h**.

## Macro Definition Documentation

### #define DAEMON\_GCC\_PRINTF\_ATTR(a, b)

A macro for making use of GCCs printf compilation warnings.

Definition at line 59 of file dlog.h.

### #define DAEMON\_LOGV\_AVAILABLE 1

This variable is defined to 1 iff **daemon\_logv()** is supported.

**Since**

0\.11

**See also**

**daemon\_logv()**

Definition at line 72 of file dlog.h.

### #define DAEMON\_SET\_VERBOSITY\_AVAILABLE 1

This variable is defined to 1 iff **daemon\_set\_verbosity()** is available.

**Since**

0\.14

**See also**

**daemon\_set\_verbosity()**

Definition at line 92 of file dlog.h.

## Enumeration Type Documentation

### enum daemon\_log\_flags

Specifies where to send the log messages to. The global variable daemon\_log\_use takes values of this type.

**Enumerator**

- *DAEMON\_LOG\_SYSLOG*

  *Log messages are written to syslog.*

- *DAEMON\_LOG\_STDERR*

  *Log messages are written to STDERR.*

- *DAEMON\_LOG\_STDOUT*

  *Log messages are written to STDOUT.*

- *DAEMON\_LOG\_AUTO*

  *If this is set a* **daemon\_fork()** *will change this to DAEMON\_LOG\_SYSLOG in the daemon process.*

*Definition at line 38 of file dlog.h.*

## Function Documentation

### char\* daemon\_ident\_from\_argv0 (char \* argv0)

*Return a sensible syslog identification for daemon\_log\_ident generated from argv\[0\]. This will return a pointer to the file name of argv\[0\], i.e. strrchr(argv\[0\], '\\')+1*

**Parameters**

*argv0 argv\[0\] as passed to main()*

**Returns**

*The identification string*

**Examples** **testd.c***.*

### void daemon\_log (int prio, const char \* t, ...)

*Log a message using printf format strings using the specified syslog priority.*

**Parameters**

*prio The syslog priority (PRIO\_xxx constants)* \
 *t,... The text message to log*

**Examples** **testd.c***.*

### void daemon\_logv (int prio, const char \* t, va\_list ap)

*Same as* **daemon\_log()***, but without variadic arguments.*

**Since**

*0.11*

**See also**

**DAEMON\_LOGV\_AVAILABLE**

### void daemon\_set\_verbosity (int verbosity\_prio)

*Setter for the verbosity level of standard output.*

**Parameters**

*verbosity\_prio Minimum priority level for messages to output on standard output/error*

*Allows to decide which messages to output on standard output/error streams. All messages are logged to syslog and this setting does not influence that.*

*The default value is LOG\_WARNING.*

**Since**

*0.14*

**See also**

**DAEMON\_SET\_VERBOSITY\_AVAILABLE**

## Variable Documentation

### const char\* daemon\_log\_ident` [extern]`

*Specifies the syslog identification, use* **daemon\_ident\_from\_argv0()** *to set this to a sensible value or generate your own.*

**Examples** **testd.c***.*

### enum daemon\_log\_flags daemon\_log\_use` [extern]`

*This variable is used to specify the log target(s) to use. Defaults to DAEMON\_LOG\_STDERR\|DAEMON\_LOG\_AUTO*

## Author

*Generated automatically by Doxygen for libdaemon from the source code.*
