src/base/cs_log.h File Reference

| programmer's documentation

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Enumerations | Functions
cs_log.h File Reference
`#include "cs_defs.h"`
`#include "cs_timer.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...
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...

## Enumeration Type Documentation

enum cs_log_t

Enumerator
CS_LOG_DEFAULT |
CS_LOG_SETUP |
CS_LOG_PERFORMANCE |
CS_LOG_N_TYPES |

## Function Documentation

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] | log | log file type
  [in] | format | format 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

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] | log | log file type

Returns
  0 upon successful completion 0 is returned. Otherwise, EOF is returned and errno is set to indicate the error.

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] | log | log file type

size_t cs_log_strlen | ( | const char * | str | ) |

Count printable length of a character string.

This should also include UTF-8 strings.

Parameters

  [in] | str | pointer to printable string

Returns
  printable length of character string.

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] | dest | pointer to destination buffer
  [in] | src | pointer to printable string
  [in] | width | desired printed length
  [in] | destsize | destination buffer size

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] | dest | pointer to destination buffer
  [in] | src | pointer to printable string
  [in] | width | desired printed length
  [in] | destsize | destination buffer size

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] | log | log file type
  [in] | indent | indentation before first column
  [in] | n_lines | number of lines in array, excluding header
  [in] | line_titles | array of titles for data lines
  [in] | calls | optional array of call counters, or NULL
  [in] | time_count | array of time counters

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] | log | log file type
  [in] | indent | indentation before first column
  [in] | header_title | title for optional header line
  [in] | calls | true if calls column is to be used