layout.h(3)

πŸ’– layout.h β€” the manual page, but make it cute πŸ’–

ok so bestie, this is layout.h(3) from the Library Functions Manual, and it's literally the whole interface for making your log events look however you want them to look. your logs? your aesthetic. periodt. ✨


🌸 NAME 🌸

layout.h β€” the interface for user-specific layout formats for log4c_logging_event events. that's it, that's the girl. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

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

πŸŽ€ Data Structures

  • struct log4c_layout_type β€” the log4c layout type class, aka the blueprint of the vibe 🫢

πŸŽ€ Macros

  • #define log4c_layout_type_define(a_type) β€” a little macro moment, more on her below

πŸŽ€ Typedefs

  • typedef struct __log4c_layout log4c_layout_t
  • typedef struct log4c_layout_type log4c_layout_type_t β€” the 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 🌈

so basically: this is the interface for user-specific layout formats for log4c_logging_event events. you want your logs to hit different? this is where you do that. πŸ‘‘

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 !! not me begging for features in the docs fr fr πŸ™ˆ

✨ Macro Definition Documentation ✨

#define log4c_layout_type_define( a_type)

a lil helper macro to define static layout types. she's helpful, she's tiny, she's doing her best. 🧚

Parameters

  • a_type β€” the log4c_layout_type_t object to define
Warning β€” needs GCC support, otherwise this macro does literally nothing. no cap. πŸ’€
Deprecated β€” this macro, and the static initialization of layouts in general, is deprecated. instead, use the log4c_layout_type_set() function to initialize your appenders before calling log4c_init(). i'm being so serious, don't use the old way bestie πŸ™ˆ

πŸ’œ Typedef Documentation πŸ’œ

typedef struct __log4c_layout log4c_layout_t

the log4c layout class. iconic behavior. πŸ‘‘

typedef struct log4c_layout_type log4c_layout_type_t

the log4c layout type class. her attributes description is:

  • name β€” layout type name
  • format

πŸ”₯ Function Documentation πŸ”₯

void log4c_layout_delete (log4c_layout_t * a_layout)

the destructor for a layout. she's leaving, say bye. πŸ‘‹


const char * log4c_layout_format (const log4c_layout_t * a_layout, const log4c_logging_event_t * a_event)

formats a log4c_logging_event events into a string. yes, that's the actual grammar in the docs, and honestly? relatable. 😌

Parameters

  • a_layout β€” the log4c_layout_t object
  • a_event β€” a logging_event_t object

Returns

an appendable string. slay. ✨


log4c_layout_t * log4c_layout_get (const char * a_name)

gets 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. (that typo is in the original, i'm preserving her, she's part of history 🫢)


const char * log4c_layout_get_name (const log4c_layout_t * a_layout)

Parameters

  • a_layout β€” the log4c_layout_t object

Returns

the layout name. cute, short, to the point. πŸ’…


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)

the constructor for a layout. brand new baby layout, welcome to the world πŸŽ€


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. she remembers what you had before, she's not judging 🫢


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. history! preserved! πŸ“œβœ¨


const log4c_layout_type_t * log4c_layout_type_get (const char * a_name)

gets 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)

ok this one is important bestie, listen up. πŸ‘‘ 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. it's giving main character energy.

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. everybody go home, the party's over 🎈


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. (not a human author, just a robot doing her best ✨)


and that's the whole page bestie!! πŸ’– this was log4c Version 1.2.4, dated with the manual page layout.h(3) β€” mwah, go forth and format your logs gorgeously. πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from