My Project
programmer's documentation
Enumerations | Functions | Variables
cs_log.h File Reference
#include "cs_defs.h"
#include "cs_timer.h"
#include "stdarg.h"
Include dependency graph for cs_log.h:

Go to the source code of this file.

Enumerations

enum  cs_log_t { CS_LOG_DEFAULT, CS_LOG_SETUP, CS_LOG_PERFORMANCE, CS_LOG_N_TYPES }
 

Functions

size_t cs_log_strlen (const char *s)
 Count printable length of a character string. More...
 
void cs_log_strpad (char *dest, const char *src, size_t width, size_t destsize)
 Pad a string so that its printable length is the required length. More...
 
void cs_log_strpadl (char *dest, const char *src, size_t width, size_t destsize)
 Pad a string on the left so that its printable length is the required length. More...
 
void cs_log_binary_pp_int32 (int32_t code, char buf[33])
 Pretty-print int-32 based bit field to string. More...
 
int cs_log_vprintf (cs_log_t log, const char *format, va_list arg_ptr)
 Print log info to a given log type. More...
 
int cs_log_printf (cs_log_t log, const char *format,...)
 Print log info to a given log type. More...
 
int cs_log_printf_flush (cs_log_t log)
 Flush output of a log file. More...
 
void cs_log_separator (cs_log_t log)
 Print a separator line in a log file. More...
 
void cs_log_timer_array_header (cs_log_t log, int indent, const char *header_title, bool calls)
 Output timing data array header to a given log. More...
 
void cs_log_timer_array (cs_log_t log, int indent, int n_lines, const char *line_titles[], const unsigned calls[], const cs_timer_counter_t time_count[])
 Output timing data block to a given log. More...
 

Variables

int cs_glob_log_frequency
 

Enumeration Type Documentation

◆ cs_log_t

enum cs_log_t
Enumerator
CS_LOG_DEFAULT 
CS_LOG_SETUP 
CS_LOG_PERFORMANCE 
CS_LOG_N_TYPES 

Function Documentation

◆ cs_log_binary_pp_int32()

void cs_log_binary_pp_int32 ( int32_t  code,
char  buf[33] 
)

Pretty-print int-32 based bit field to string.

Parameters
[in]codevalue to print
[out]bufoutput buffer (must be at least 33 bytes).

◆ cs_log_printf()

int cs_log_printf ( cs_log_t  log,
const char *  format,
  ... 
)

Print log info to a given log type.

The format and variable arguments are similar to those of the printf() type functions.

In parallel, output is only handled by rank 0.

Parameters
[in]loglog file type
[in]formatformat string, as printf() and family.
[in]...variable arguments based on format string.
Returns
number of characters printed, not counting the trailing '\0' used to end output strings

◆ cs_log_printf_flush()

int cs_log_printf_flush ( cs_log_t  log)

Flush output of a log file.

In parallel, output is only handled by rank 0.

If the argument is set to CS_LOG_N_TYPES, all log files are flushed.

Parameters
[in]loglog file type
Returns
0 upon successful completion 0 is returned. Otherwise, EOF is returned and errno is set to indicate the error.

◆ cs_log_separator()

void cs_log_separator ( cs_log_t  log)

Print a separator line in a log file.

In parallel, output is only handled by rank 0.

Parameters
[in]loglog file type

◆ cs_log_strlen()

size_t cs_log_strlen ( const char *  str)

Count printable length of a character string.

This should also include UTF-8 strings.

Parameters
[in]strpointer to printable string
Returns
printable length of character string.

◆ cs_log_strpad()

void cs_log_strpad ( char *  dest,
const char *  src,
size_t  width,
size_t  destsize 
)

Pad a string so that its printable length is the required length.

This allows pretty-printing with UTF-8 strings, whose actual length may be larger than their printable length in the presence of multibyte characters.

If either the printable length of the string is longer than the target width or the actual length is long than the destination buffer's size, it is truncated.

Parameters
[out]destpointer to destination buffer
[in]srcpointer to printable string
[in]widthdesired printed length
[in]destsizedestination buffer size

◆ cs_log_strpadl()

void cs_log_strpadl ( char *  dest,
const char *  src,
size_t  width,
size_t  destsize 
)

Pad a string on the left so that its printable length is the required length.

This allows pretty-printing with UTF-8 strings, whose actual length may be larger than their printable length in the presence of multibyte characters.

If either the printable length of the string is longer than the target width or the actual length is long than the destination buffer's size, it is truncated.

Parameters
[out]destpointer to destination buffer
[in]srcpointer to printable string
[in]widthdesired printed length
[in]destsizedestination buffer size

◆ cs_log_timer_array()

void cs_log_timer_array ( cs_log_t  log,
int  indent,
int  n_lines,
const char *  line_titles[],
const unsigned  calls[],
const cs_timer_counter_t  time_count[] 
)

Output timing data block to a given log.

If the optional array of call counters is used, only lines with a number of calls greater than 0 are logged.

In parallel, output is only handled by rank 0.

Parameters
[in]loglog file type
[in]indentindentation before first column
[in]n_linesnumber of lines in array, excluding header
[in]line_titlesarray of titles for data lines
[in]callsoptional array of call counters, or NULL
[in]time_countarray of time counters

◆ cs_log_timer_array_header()

void cs_log_timer_array_header ( cs_log_t  log,
int  indent,
const char *  header_title,
bool  calls 
)

Output timing data array header to a given log.

In parallel, output is only handled by rank 0.

Parameters
[in]loglog file type
[in]indentindentation before first column
[in]header_titletitle for optional header line
[in]callstrue if calls column is to be used

◆ cs_log_vprintf()

int cs_log_vprintf ( cs_log_t  log,
const char *  format,
va_list  arg_ptr 
)

Print log info to a given log type.

The format and variable arguments are similar to those of the vprintf() type functions.

In parallel, output is only handled by rank 0.

Parameters
[in]loglog file type
[in]formatformat string, as printf() and family.
[in]arg_ptrvariable arguments list pointer
Returns
number of characters printed, not counting the trailing '\0' used to end output strings

Variable Documentation

◆ cs_glob_log_frequency

int cs_glob_log_frequency