---
name: "log4c_layout.h"
section: "3"
platform: "linux"
package: "liblog4c-doc"
version: "1.2.4-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/log4c_layout.h"
---

# log4c\_layout.h(3)

Interface for user specific layout format of log4c\_logging\_event events.

## NAME

layout.h - Interface for user specific layout format of log4c\_logging\_event events.

## SYNOPSIS

`#include <log4c/defs.h>`\
 `#include <log4c/logging_event.h>`\
 `#include <stdio.h>`\

### Data Structures

struct **log4c\_layout\_type**\
 log4c layout type class

### Macros

\#define **log4c\_layout\_type\_define**(a\_type)\

### Typedefs

typedef struct \_\_log4c\_layout **log4c\_layout\_t**\
 typedef struct **log4c\_layout\_type** **log4c\_layout\_type\_t**\
 log4c layout type class

### Functions

const **log4c\_layout\_type\_t** \* **log4c\_layout\_type\_get** (const char \*a\_name)\
 const **log4c\_layout\_type\_t** \* **log4c\_layout\_type\_set** (const **log4c\_layout\_type\_t** \*a\_type)\
 **log4c\_layout\_t** \* **log4c\_layout\_get** (const char \*a\_name)\
 **log4c\_layout\_t** \* **log4c\_layout\_new** (const char \*a\_name)\
 void **log4c\_layout\_delete** (**log4c\_layout\_t** \*a\_layout)\
 const char \* **log4c\_layout\_get\_name** (const **log4c\_layout\_t** \*a\_layout)\
 const **log4c\_layout\_type\_t** \* **log4c\_layout\_get\_type** (const **log4c\_layout\_t** \*a\_layout)\
 const **log4c\_layout\_type\_t** \* **log4c\_layout\_set\_type** (**log4c\_layout\_t** \*a\_layout, const **log4c\_layout\_type\_t** \*a\_type)\
 void \* **log4c\_layout\_get\_udata** (const **log4c\_layout\_t** \*a\_layout)\
 void \* **log4c\_layout\_set\_udata** (**log4c\_layout\_t** \*a\_layout, void \*a\_udata)\
 const char \* **log4c\_layout\_format** (const **log4c\_layout\_t** \*a\_layout, const **log4c\_logging\_event\_t** \*a\_event)\
 void **log4c\_layout\_print** (const **log4c\_layout\_t** \*a\_layout, FILE \*a\_stream)\
 void **log4c\_layout\_types\_free** (void)\
 void **log4c\_layout\_types\_print** (FILE \*fp)\

## Detailed Description

Interface for user specific layout format of log4c\_logging\_event events.

**Todo**

the layout interface needs a better configuration system depending on the layout type. The udata field is a just a trick.

**Todo**

a pattern layout would be welcomed !!

## Macro Definition Documentation

### #define log4c\_layout\_type\_define(a\_type)

Helper macro to define static layout types.

**Parameters**

*a\_type* the log4c\_layout\_type\_t object to define

**Warning**

needs GCC support: otherwise this macro does nothing

**Deprecated**

This macro, and the static initialialization of layouts in general, is deprecated. Use rather the **log4c\_layout\_type\_set()** function to initialize your appenders before calling log4c\_init()

## Typedef Documentation

### typedef struct \_\_log4c\_layout log4c\_layout\_t

log4c layout class

### typedef struct log4c\_layout\_type log4c\_layout\_type\_t

log4c layout type class Attributes description:

- •

  `name` layout type name

- •

  `format`

## Function Documentation

### void log4c\_layout\_delete (log4c\_layout\_t \* a\_layout)

Destructor for layout.

### const char \* log4c\_layout\_format (const log4c\_layout\_t \* a\_layout, const log4c\_logging\_event\_t \* a\_event)

format a log4c\_logging\_event events to a string.

**Parameters**

*a\_layout* the log4c\_layout\_t object \
 *a\_event* a logging\_event\_t object

**Returns**

an appendable string.

### log4c\_layout\_t \* log4c\_layout\_get (const char \* a\_name)

Get a pointer to an existing layout.

**Parameters**

*a\_name* the name of the layout to return.

**Returns**

a pointer to an existing layout, or NULL if no layout with the specfied name exists.

### const char \* log4c\_layout\_get\_name (const log4c\_layout\_t \* a\_layout)

**Parameters**

*a\_layout* the log4c\_layout\_t object

**Returns**

the layout name

### const log4c\_layout\_type\_t \* log4c\_layout\_get\_type (const log4c\_layout\_t \* a\_layout)

**Parameters**

*a\_layout* the log4c\_layout\_t object

**Returns**

a log4c\_layout\_type\_t object

### void \* log4c\_layout\_get\_udata (const log4c\_layout\_t \* a\_layout)

**Parameters**

*a\_layout* the log4c\_layout\_t object

**Returns**

the layout user data

### log4c\_layout\_t \* log4c\_layout\_new (const char \* a\_name)

Constructor for layout.

### void log4c\_layout\_print (const log4c\_layout\_t \* a\_layout, FILE \* a\_stream)

prints the layout on a stream

**Parameters**

*a\_layout* the log4c\_layout\_t object \
 *a\_stream* the stream

### const log4c\_layout\_type\_t \* log4c\_layout\_set\_type (log4c\_layout\_t \* a\_layout, const log4c\_layout\_type\_t \* a\_type)

sets the layout type

**Parameters**

*a\_layout* the log4c\_layout\_t object \
 *a\_type* the new layout type

**Returns**

the previous layout type

### void \* log4c\_layout\_set\_udata (log4c\_layout\_t \* a\_layout, void \* a\_udata)

sets the layout user data

**Parameters**

*a\_layout* the log4c\_layout\_t object \
 *a\_udata* the new layout user data

**Returns**

the previous layout user data

### const log4c\_layout\_type\_t \* log4c\_layout\_type\_get (const char \* a\_name)

Get a pointer to an existing layout type.

**Parameters**

*a\_name* the name of the layout type to return. \

**Returns**

a pointer to an existing layout type, or NULL if no layout type with the specified name exists.

### const log4c\_layout\_type\_t \* log4c\_layout\_type\_set (const log4c\_layout\_type\_t \* a\_type)

Use this function to register a layout type with log4c. Once this is done you may refer to this type by name both programatically and in the log4c configuration file.

**Parameters**

*a\_type* a pointer to the new layout type to set.

**Returns**

a pointer to the previous layout type of same name.

Example code fragment:

```
const log4c_layout_type_t log4c_layout_type_xml = {
   "s13_xml",
   xml_format,
};
log4c_layout_type_set(&log4c_layout_type_xml);
```

### void log4c\_layout\_types\_free (void)

free all layout types

### void log4c\_layout\_types\_print (FILE \* fp)

prints all the current registered layout types on a stream

**Parameters**

*fp* the stream

## Author

Generated automatically by Doxygen for log4c from the source code.
