RESPOND 2.5.1
Researching Effective Strategies to Prevent Opioid Death
Loading...
Searching...
No Matches
logging.hpp
1
2// File: logging.hpp //
3// Project: respond //
4// Created Date: 2025-06-02 //
5// Author: Matthew Carroll //
6// ----- //
7// Last Modified: 2025-07-30 //
8// Modified By: Matthew Carroll //
9// ----- //
10// Copyright (c) 2025 Syndemics Lab at Boston Medical Center //
12#ifndef RESPOND_LOGGING_HPP_
13#define RESPOND_LOGGING_HPP_
14
15#include <string>
16
17#include <respond/logging_config.hpp>
18
19namespace respond {
20
22enum class LogType : int {
23 kInfo = 0, // Information Messages
24 kWarn = 1, // Warning Messages
25 kError = 2, // Error Messages
26 kDebug = 3, // Debug Messages
27 kCount = 4 // Enum Counter
28};
29
31enum class CreationStatus : int {
32 kError = -1, // Error Creating Logger
33 kSuccess = 0, // Logger Created Successfully
34 kExists = 1, // Logger Already Exists
35 kNotCreated = 2, // Logger Not Created
36 kCount = 4 // Enum Counter
37};
38
40enum class LogPattern : int {
41 kSimple = 0, // Minimal: [%n] %v
42 kStandard = 1, // Default: [%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v
43 kDetailed = 2, // Full: [%Y-%m-%d %H:%M:%S.%e] [%n] [%^%L%$] [thread %t] %v
44 kThreadSafe =
45 3 // With sequence number: [%H:%M:%S] [seq %i] [%n] [%^---%L---%$] %v
46};
47
48// ============================================================================
49// Core Logger Creation and Management
50// ============================================================================
51
60CreationStatus CreateFileLogger(const std::string &logger_name,
61 const std::string &filepath);
62
68CreationStatus ConfigureLogger(const LoggingConfig &config);
69
70// ============================================================================
71// Parallel Execution Support: Shared File Sink
72// ============================================================================
73
81CreationStatus CreateSharedFileSink(const std::string &filepath);
82
93CreationStatus CreateSharedLogger(const std::string &logger_name);
94
100void SetLogPattern(LogPattern pattern);
101
104LogPattern GetLogPattern();
105
110void SetFlushInterval(int seconds);
111
115void FlushAllLoggers();
116
117// ============================================================================
118// Logging Functions
119// ============================================================================
120
128void LogInfo(const std::string &logger_name, const std::string &message);
129
136void LogWarning(const std::string &logger_name, const std::string &message);
137
144void LogError(const std::string &logger_name, const std::string &message);
145
152void LogDebug(const std::string &logger_name, const std::string &message);
153
154// ============================================================================
155// Utility Functions
156// ============================================================================
157
162CreationStatus CheckLoggerExists(const std::string &logger_name);
163
169std::string GetLoggerInfo(const std::string &logger_name);
170
176void SetLoggerLevel(const std::string &logger_name, int level);
177
178} // namespace respond
179
180#endif // RESPOND_LOGGING_HPP_