LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
log_api.h
Go to the documentation of this file.
1/*
2 MIT License
3
4 Copyright (c) 2025 Robin A. Onsay
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16*/
17
37#ifndef JUNO_LOG_API_H
38#define JUNO_LOG_API_H
39#include "juno/macros.h"
40#include "juno/status.h"
41#include "juno/module.h"
42#ifdef __cplusplus
43extern "C"
44{
45#endif
46
48
49typedef struct JUNO_LOG_ROOT_TAG JUNO_LOG_ROOT_T;
50
52
54{
56 JUNO_STATUS_T (*LogDebug)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg, ...);
58 JUNO_STATUS_T (*LogInfo)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg, ...);
60 JUNO_STATUS_T (*LogWarning)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg, ...);
62 JUNO_STATUS_T (*LogError)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg, ...);
63};
64
66static inline JUNO_STATUS_T JunoLog_LogInit(JUNO_LOG_ROOT_T *ptLog, const JUNO_LOG_API_T *ptApi, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, JUNO_USER_DATA_T *pvUserData)
67{
68 JUNO_ASSERT_EXISTS(ptLog);
69 ptLog->_pfcnFailureHandler = pfcnFailureHandler;
70 ptLog->_pvFailureUserData = pvUserData;
71 ptLog->ptApi = ptApi;
73}
74
75#ifdef __cplusplus
76}
77#endif
78#endif // JUNO_LOG_API_H
#define JUNO_ASSERT_EXISTS(ptr)
Returns JUNO_STATUS_NULLPTR_ERROR if the expression is falsy.
Definition macros.h:50
#define JUNO_MODULE_EMPTY
Helper for module definitions with no additional members.
Definition module.h:86
#define JUNO_MODULE_ROOT(API_T,...)
Implement a module root struct containing ptApi and failure fields.
Definition module.h:126
#define JUNO_STATUS_SUCCESS
Operation completed successfully.
Definition status.h:56
void(* JUNO_FAILURE_HANDLER_T)(JUNO_STATUS_T tStatus, const char *pcCustomMessage, JUNO_USER_DATA_T *pvUserData)
Failure handler callback signature.
Definition status.h:104
int32_t JUNO_STATUS_T
Canonical status type for LibJuno functions.
Definition status.h:49
void JUNO_USER_DATA_T
Opaque user data type for failure callbacks.
Definition status.h:96
struct JUNO_LOG_ROOT_TAG JUNO_LOG_ROOT_T
Definition log_api.h:49
static JUNO_STATUS_T JunoLog_LogInit(JUNO_LOG_ROOT_T *ptLog, const JUNO_LOG_API_T *ptApi, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, JUNO_USER_DATA_T *pvUserData)
Initialize a log instance with an API implementation and failure handler.
Definition log_api.h:66
Common assertion and helper macros for LibJuno modules.
Module system and dependency injection primitives for LibJuno.
Status codes and failure-handling helpers for LibJuno.
Definition log_api.h:54
JUNO_STATUS_T(* LogError)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg,...)
Log an error-level message.
Definition log_api.h:62
JUNO_STATUS_T(* LogWarning)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg,...)
Log a warning-level message.
Definition log_api.h:60
JUNO_STATUS_T(* LogDebug)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg,...)
Log a debug-level message (most verbose).
Definition log_api.h:56
JUNO_STATUS_T(* LogInfo)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg,...)
Log an info-level message.
Definition log_api.h:58