RESPOND 2.4.0
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
17namespace respond {
18
20enum class LogType : int {
21 kInfo = 0, // Information Messages
22 kWarn = 1, // Warning Messages
23 kError = 2, // Error Messages
24 kDebug = 3, // Debug Messages
25 kCount = 4 // Enum Counter
26};
27
29enum class CreationStatus : int {
30 kError = -1, // Error Creating Logger
31 kSuccess = 0, // Logger Created Successfully
32 kExists = 1, // Logger Already Exists
33 kNotCreated = 2, // Logger Not Created
34 kCount = 4 // Enum Counter
35};
36
38enum class LogPattern : int {
39 kSimple = 0, // Minimal: [%n] %v
40 kStandard = 1, // Default: [%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v
41 kDetailed = 2, // Full: [%Y-%m-%d %H:%M:%S.%e] [%n] [%^%L%$] [thread %t] %v
42 kThreadSafe =
43 3 // With sequence number: [%H:%M:%S] [seq %i] [%n] [%^---%L---%$] %v
44};
45
46// ============================================================================
47// Core Logger Creation and Management
48// ============================================================================
49
56CreationStatus CreateFileLogger(const std::string &logger_name,
57 const std::string &filepath);
58
59// ============================================================================
60// Parallel Execution Support: Shared File Sink
61// ============================================================================
62
70CreationStatus CreateSharedFileSink(const std::string &filepath);
71
81CreationStatus CreateSharedLogger(const std::string &logger_name);
82
88void SetLogPattern(LogPattern pattern);
89
92LogPattern GetLogPattern();
93
98void SetFlushInterval(int seconds);
99
103void FlushAllLoggers();
104
105// ============================================================================
106// Logging Functions
107// ============================================================================
108
114void LogInfo(const std::string &logger_name, const std::string &message);
115
120void LogWarning(const std::string &logger_name, const std::string &message);
121
126void LogError(const std::string &logger_name, const std::string &message);
127
132void LogDebug(const std::string &logger_name, const std::string &message);
133
134// ============================================================================
135// Utility Functions
136// ============================================================================
137
142CreationStatus CheckLoggerExists(const std::string &logger_name);
143
148std::string GetLoggerInfo(const std::string &logger_name);
149
156void SetLoggerLevel(const std::string &logger_name, int level);
157
158} // namespace respond
159
160#endif // RESPOND_LOGGING_HPP_