LibJuno 1.0.4
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
51// @{"req": ["REQ-LOG-001"]}
53
55{
57 // @{"req": ["REQ-LOG-002", "REQ-LOG-007"]}
58 JUNO_STATUS_T (*LogDebug)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg, ...);
60 // @{"req": ["REQ-LOG-003", "REQ-LOG-007"]}
61 JUNO_STATUS_T (*LogInfo)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg, ...);
63 // @{"req": ["REQ-LOG-004", "REQ-LOG-007"]}
64 JUNO_STATUS_T (*LogWarning)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg, ...);
66 // @{"req": ["REQ-LOG-005", "REQ-LOG-007"]}
67 JUNO_STATUS_T (*LogError)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg, ...);
68};
69
71// @{"req": ["REQ-LOG-006"]}
72static 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)
73{
74 JUNO_ASSERT_EXISTS(ptLog);
75 ptLog->_pfcnFailureHandler = pfcnFailureHandler;
76 ptLog->_pvFailureUserData = pvUserData;
77 ptLog->ptApi = ptApi;
79}
80
81#ifdef __cplusplus
82}
83#endif
84#endif // JUNO_LOG_API_H
#define JUNO_ASSERT_EXISTS(ptr)
Returns JUNO_STATUS_NULLPTR_ERROR if the expression is falsy.
Definition macros.h:51
#define JUNO_MODULE_EMPTY
Helper for module definitions with no additional members.
Definition module.h:87
#define JUNO_MODULE_ROOT(API_T,...)
Implement a module root struct containing ptApi and failure fields.
Definition module.h:129
#define JUNO_STATUS_SUCCESS
Operation completed successfully.
Definition status.h:59
void(* JUNO_FAILURE_HANDLER_T)(JUNO_STATUS_T tStatus, const char *pcCustomMessage, JUNO_USER_DATA_T *pvUserData)
Failure handler callback signature.
Definition status.h:110
int32_t JUNO_STATUS_T
Canonical status type for LibJuno functions.
Definition status.h:51
void JUNO_USER_DATA_T
Opaque user data type for failure callbacks.
Definition status.h:101
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:72
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:55
JUNO_STATUS_T(* LogError)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg,...)
Log an error-level message.
Definition log_api.h:67
JUNO_STATUS_T(* LogWarning)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg,...)
Log a warning-level message.
Definition log_api.h:64
JUNO_STATUS_T(* LogDebug)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg,...)
Log a debug-level message (most verbose).
Definition log_api.h:58
JUNO_STATUS_T(* LogInfo)(const JUNO_LOG_ROOT_T *ptJunoLog, const char *pcMsg,...)
Log an info-level message.
Definition log_api.h:61