OpenShot Library | libopenshot 1.1.1
Loading...
Searching...
No Matches
Logger.h
Go to the documentation of this file.
1// Copyright (c) 2008-2026 OpenShot Studios, LLC
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#ifndef OPENSHOT_LOGGER_H
4#define OPENSHOT_LOGGER_H
5
6#include <atomic>
7#include <fstream>
8#include <mutex>
9#include <string>
10
11namespace openshot {
12class Settings;
14class Logger {
15public:
16 enum Level { LevelDebug = 10, LevelInfo = 20, LevelWarning = 30, LevelError = 40, LevelCritical = 50, LevelOff = 100 };
17 static Logger* Instance();
19 void SetFileLevel(std::string level);
20 void SetConsoleLevel(std::string level);
21 bool ShouldLog(Level level = LevelDebug) const;
22 void Path(std::string path);
23 void Close();
24 void Log(std::string message, Level level = LevelDebug);
26 void LogToFile(std::string message);
28 void Enable(bool enabled);
30 void Connection(std::string connection) {}
31 void AppendDebugMethod(std::string method_name,
32 std::string arg1_name="", float arg1_value=-1.0,
33 std::string arg2_name="", float arg2_value=-1.0,
34 std::string arg3_name="", float arg3_value=-1.0,
35 std::string arg4_name="", float arg4_value=-1.0,
36 std::string arg5_name="", float arg5_value=-1.0,
37 std::string arg6_name="", float arg6_value=-1.0);
38private:
39 Logger();
40 Settings* legacy_settings;
41 Logger(const Logger&) = delete;
42 Logger& operator=(const Logger&) = delete;
43 std::recursive_mutex loggerMutex;
44 std::ofstream log_file;
45 std::string file_path;
46 std::atomic<int> file_level{LevelInfo};
47 std::atomic<int> console_level{LevelInfo};
48 std::atomic<bool> file_open{false};
49 std::atomic<bool> console_configured{false};
50 int ConsoleLevel() const;
51};
52}
53#endif
Independent file and stderr logging. No networking or worker thread.
Definition Logger.h:14
void AppendDebugMethod(std::string method_name, std::string arg1_name="", float arg1_value=-1.0, std::string arg2_name="", float arg2_value=-1.0, std::string arg3_name="", float arg3_value=-1.0, std::string arg4_name="", float arg4_value=-1.0, std::string arg5_name="", float arg5_value=-1.0, std::string arg6_name="", float arg6_value=-1.0)
Definition Logger.cpp:168
void SetFileLevel(std::string level)
Explicit configuration overrides environment defaults. Invalid levels throw.
Definition Logger.cpp:104
void SetConsoleLevel(std::string level)
Definition Logger.cpp:105
void Path(std::string path)
Definition Logger.cpp:111
void Connection(std::string connection)
Deprecated compatibility no-op; logging no longer uses connections.
Definition Logger.h:30
void Enable(bool enabled)
Compatibility: enable debug file output, or disable ordinary file output.
Definition Logger.cpp:109
bool ShouldLog(Level level=LevelDebug) const
Definition Logger.cpp:101
void LogToFile(std::string message)
Unfiltered raw output, retained for the existing crash handler.
Definition Logger.cpp:142
void Log(std::string message, Level level=LevelDebug)
Definition Logger.cpp:146
static Logger * Instance()
Definition Logger.cpp:55
This class is contains settings used by libopenshot (and can be safely toggled at any point)
Definition Settings.h:26
This namespace is the default namespace for all code in the openshot library.