Mercurial > molko
view libmlk-core/mlk/core/trace.h @ 564:e91f37da2992
core: doxygenize window
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 08 Mar 2023 20:09:21 +0100 |
parents | 970cad994a95 |
children |
line wrap: on
line source
/* * trace.h -- non-fatal message logs * * Copyright (c) 2020-2023 David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef MLK_CORE_TRACE_H #define MLK_CORE_TRACE_H /** * \file mlk/core/trace.h * \brief Non-fatal message logs * * This module provides a simple way to log messages from the API or user code, * mostly when non-fatal errors happened. * * The default implementation uses printf with a timestamp in the form hh:mm::s * to the standard output, it can be disabled using your own * ::mlk_trace_handler or setting it to NULL. * * Example of lines generated by default: * * ``` * 10:20:30: hello world * 20:50:00: goodbye world * ``` */ #include <stdarg.h> /** * Maximum trace line */ #define MLK_TRACE_LINE_MAX (128) /** * Default trace handler implementation * * Can be set to NULL to disable logging. * * \param line the line to print */ extern void (*mlk_trace_handler)(const char *line); #if defined(__cplusplus) extern "C" { #endif /** * Write a trace log using a [printf] format style. * * [printf]: https://en.cppreference.com/w/c/io/fprintf * * \pre fmt != NULL * \param fmt the printf format string */ void mlk_tracef(const char *fmt, ...); /** * Similar to ::mlk_tracef but using a `va_list` instead. * * \pre fmt != NULL * \param fmt the printf format string * \param ap the variadic handle */ void mlk_traceva(const char *fmt, va_list ap); #if defined(__cplusplus) } #endif #endif /* !MLK_CORE_TRACE_H */