Log format string processing

Overview

Some TE-specific features, such as memory dump, file content logging, and additional length modifiers are supported. More…

// typedefs

typedef enum te_log_msg_arg_type te_log_msg_arg_type;
typedef struct te_log_msg_out te_log_msg_out;

typedef te_errno (*te_log_msg_fmt_args_f)(
    te_log_msg_out *out,
    const char *fmt,
    va_list ap
    );

typedef te_errno (*te_log_msg_raw_arg_f)(
    te_log_msg_out *out,
    const char *fmt,
    size_t fmt_len,
    te_log_msg_arg_type arg_type,
    const void *arg_addr,
    size_t arg_len
    );

typedef struct te_log_arg_descr te_log_arg_descr;
typedef struct te_log_msg_raw_data te_log_msg_raw_data;
typedef struct te_log_msg_truncated te_log_msg_truncated;

// enums

enum te_log_msg_arg_type;

// structs

struct te_log_arg_descr;
struct te_log_msg_out;
struct te_log_msg_raw_data;
struct te_log_msg_truncated;

// global variables

const struct te_log_msg_out te_log_msg_out_raw;

// global functions

te_errno te_log_vprintf(te_log_msg_out* out, const char* fmt, va_list ap);
te_errno te_log_message_raw_va(te_log_msg_raw_data* data, te_log_ts_sec ts_sec, te_log_ts_usec ts_usec, te_log_level level, te_log_id log_id, const char* entity, const char* user, const char* fmt, va_list ap);
te_errno te_log_message_split(const char* file, unsigned int line, unsigned int level, const char* entity, const char* user, const char* fmt, ...);

Detailed Documentation

Some TE-specific features, such as memory dump, file content logging, and additional length modifiers are supported.

Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved.

Typedefs

typedef enum te_log_msg_arg_type te_log_msg_arg_type

Types of TE log message arguments

typedef te_errno (*te_log_msg_fmt_args_f)(
    te_log_msg_out *out,
    const char *fmt,
    va_list ap
    )

Callback to process possibly few format string arguments in vprintf()-like mode.

Parameters:

out

Backend parameters

fmt

Part of format string, terminated by NUL, which corresponds to arguments pointed by ap

ap

Arguments for format string

Returns:

FIXME

typedef te_errno (*te_log_msg_raw_arg_f)(
    te_log_msg_out *out,
    const char *fmt,
    size_t fmt_len,
    te_log_msg_arg_type arg_type,
    const void *arg_addr,
    size_t arg_len
    )

Callback to process one format string argument in raw mode.

Parameters:

out

Backend parameters

fmt

Part of format string which corresponds to the argument (possibly not terminated by NUL) or NULL

fmt_len

Length of the fmt (zero, if fmt is NULL)

arg_type

Type of the argument

arg_addr

Address of the argument

arg_len

Argument length

Returns:

FIXME

typedef struct te_log_arg_descr te_log_arg_descr

Log argument descriptor

typedef struct te_log_msg_raw_data te_log_msg_raw_data

Raw logging backend parameters

typedef struct te_log_msg_truncated te_log_msg_truncated

Information about truncated part of raw log argument.

Global Functions

te_errno te_log_vprintf(te_log_msg_out* out, const char* fmt, va_list ap)

Preprocess and output message to log with special features parsing.

Parameters:

out

Output parameters

fmt

Format string

ap

Arguments for the format string

Returns:

Error code (see te_errno.h)

te_errno te_log_message_raw_va(te_log_msg_raw_data* data, te_log_ts_sec ts_sec, te_log_ts_usec ts_usec, te_log_level level, te_log_id log_id, const char* entity, const char* user, const char* fmt, va_list ap)

Parameters:

data

Output parameters

ts_sec

Timestamp seconds

ts_usec

Timestamp microseconds

level

Log levelt

log_id

Test ID or TE_LOG_ID_UNDEFINED

entity

Entity name

user

User name

fmt

Format string

ap

Arguments for the format string

Returns:

Error code (see te_errno.h)

te_errno te_log_message_split(const char* file, unsigned int line, unsigned int level, const char* entity, const char* user, const char* fmt, ...)

Print a given string in log, splitting it in multiple messages if it is too long to fit in a single one.

This function does not parse TE format specifiers like ‘r’, and involves some processing overhead. So use it only when it is necessary. This function will try to split the string at ‘

‘ symbols (removing them from the beginning and the end of each message). If it is not possible, it will cut the string at arbitrary positions.

Parameters:

file

Name of file where this function is called (use FILE)

line

Number of line where this function is called (use LINE)

level

Log level

entity

Logger entity

user

Logger user

fmt

Format string

Format string arguments

Returns:

Status code