Files
djhackersdev_bemanitools/src/main/core/log.c
T
icex2 df8bf56d0c feat: Add core module
This module contains the "core" (API) of
bemanitools which includes an abstraction
layer for threads and logging at this time.

The threads API is very close to what
util/thread already was with some structural
enhancements which make it easier to understand
and work with the API, I hope. Some additional
helpers (*-ext module) support in doing common
tasks, e.g. setting up the thread API with other
modules.

The log(ging) part receives a major overhaul to
address known limitations and issues with the
util/log module:
- Cleaner API layer
- Separate sinks from actual logging engine
- Sinks are composable
- Improved and cleaner compatibility layer
  with AVS logging API

Additional "extensions" (*-ext modules) add
various helper functions for common tasks like
setting up the logging engine with a file and stdout
sink.

The sinks also improved significantly with the file
sink now supporting proper appending and log rotation.
Logging to stdout/stderr supports coloring of log
messages which works across logging engines.

Overall, this refactored foundation is expected to
support future developments and removes known
limitations at the current scale of bemanitools such as:
- Reducing boiler plate code across hooks
- Interop of bemanitools and AVS (and setting the foundation
  for addressing currently missing interop, e.g. for
  dealing with property structures without AVS)
- Addressing performance issues in the logging engine
  due to incorrect interop with AVS
2024-02-25 09:36:53 +01:00

74 lines
1.5 KiB
C

#include <stdlib.h>
#include "core/log.h"
core_log_message_t _core_log_misc_impl;
core_log_message_t _core_log_info_impl;
core_log_message_t _core_log_warning_impl;
core_log_message_t _core_log_fatal_impl;
void core_log_impl_set(
core_log_message_t misc,
core_log_message_t info,
core_log_message_t warning,
core_log_message_t fatal)
{
if (misc == NULL || info == NULL || warning == NULL || fatal == NULL) {
abort();
}
_core_log_misc_impl = misc;
_core_log_info_impl = info;
_core_log_warning_impl = warning;
_core_log_fatal_impl = fatal;
}
void core_log_impl_assign(core_log_impl_set_t impl_set)
{
if (_core_log_misc_impl == NULL || _core_log_info_impl == NULL ||
_core_log_warning_impl == NULL || _core_log_fatal_impl == NULL) {
abort();
}
impl_set(
_core_log_misc_impl,
_core_log_info_impl,
_core_log_warning_impl,
_core_log_fatal_impl);
}
core_log_message_t core_log_misc_impl_get()
{
if (_core_log_misc_impl == NULL) {
abort();
}
return _core_log_misc_impl;
}
core_log_message_t core_log_info_impl_get()
{
if (_core_log_info_impl == NULL) {
abort();
}
return _core_log_info_impl;
}
core_log_message_t core_log_warning_impl_get()
{
if (_core_log_warning_impl == NULL) {
abort();
}
return _core_log_warning_impl;
}
core_log_message_t core_log_fatal_impl_get()
{
if (_core_log_fatal_impl == NULL) {
abort();
}
return _core_log_fatal_impl;
}