NDEVR
API Documentation
LogManager.h
1#pragma once
2#include <NDEVR/Dictionary.h>
3#include <NDEVR/String.h>
4#include <NDEVR/Log.h>
5#include <NDEVR/BinaryFile.h>
6namespace NDEVR
7{
14 class LogManager : public InfoPipe
15 {
16 public:
26
31 NDEVR_BASE_API bool hasLog(const StringView& log_name) const;
37 NDEVR_BASE_API InfoPipe* getLog(const StringView& log_name) const;
42 InfoPipe* defaultLog() const
43 {
44 return getLog("DEFAULT");
45 }
46
58 NDEVR_BASE_API void addStream(LogStream* stream, bool add_all) override;
64 NDEVR_BASE_API void addLog(const StringView& name, InfoPipe* info);
69 NDEVR_BASE_API void removeStream(LogStream* stream) override;
75 NDEVR_BASE_API void setDefaultAsciiLogPath(const File& file, MoveMode mode);
80 NDEVR_BASE_API const Dictionary<String, InfoPipe*>& logs();
87 NDEVR_BASE_API virtual void addMessage(uint04 id, const TranslatedString&, uint01 = 10) override;
93 NDEVR_BASE_API virtual void addMessage(uint04 id, const LogMessage&) override;
100 NDEVR_BASE_API virtual void addMessage(uint04 id, const StringView&, uint01 = 10) override;
106 NDEVR_BASE_API virtual void addMessages(uint04 id, const Buffer<LogMessage>&) override;
111 NDEVR_BASE_API void logStartupInformation(const StringView& log) const;
115 NDEVR_BASE_API void requestCancel() override;
120 NDEVR_BASE_API virtual void requestCancel(uint04 idx) override;
126 NDEVR_BASE_API void readFromFile(BinaryFile& file, uint08 version_number);
132 NDEVR_BASE_API void setProgressIdx(uint04 idx, fltp04 percent) final override;
138 NDEVR_BASE_API fltp04 progressIdx(uint04 idx) const final override;
144 NDEVR_BASE_API void addInput(const StringView& s, uint04 idx) final override;
149 NDEVR_BASE_API void addInput(const StringView& s) final override;
150 private:
157 NDEVR_BASE_API uint04 addProgressSource(const TranslatedString& name, fltp04 progress) final override;
164 NDEVR_BASE_API void addProgressSource(const TranslatedString& name, uint04 idx, fltp04 progress) final override;
169 NDEVR_BASE_API void removeProgressSource(uint04 idx) final override;
175 NDEVR_BASE_API uint04 addCancelGuard(const TranslatedString& name) final override;
181 NDEVR_BASE_API void addCancelGuard(const TranslatedString& name, uint04 idx) final override;
186 NDEVR_BASE_API void removeCancelGuard(uint04 idx) final override;
192 NDEVR_BASE_API bool cancelRequestedIdx(uint04 idx) const final override;
197 NDEVR_BASE_API bool cancelRequested() const final override;
203 NDEVR_BASE_API uint04 addInputGuard(const TranslatedString& name) final override;
209 NDEVR_BASE_API void addInputGuard(const TranslatedString& name, uint04 idx) final override;
214 NDEVR_BASE_API void removeInputGuard(uint04 idx) final override;
221 NDEVR_BASE_API void getInputIdx(String& s, uint04 idx, bool clear) final override;
226 NDEVR_BASE_API void clearInputIdx(uint04 idx) final override;
227 private:
228 mutable Dictionary<String, InfoPipe*> m_logs;
229 Buffer<LogStream*> m_streams;
230 Dictionary<String, AsciiFileOutputStream*> m_ascii_streams;
231 File m_default_ascii_log_path;
232 };
233}
A LogStream that writes log messages directly to a specified ASCII text file.
Logic for reading or writing to a binary file including logic for compressing or decompressing the fi...
Definition BinaryFile.h:136
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
void removeInputGuard(uint04 idx) final override
Removes an input guard by index from all child logs.
virtual void addMessage(uint04 id, const LogMessage &) override
Adds a structured log message to all child logs.
bool cancelRequested() const final override
Checks whether any cancellation has been requested across all child logs.
virtual void requestCancel(uint04 idx) override
Requests cancellation of a specific operation by index across all child logs.
uint04 addInputGuard(const TranslatedString &name) final override
Adds a new input guard with the given name.
void addProgressSource(const TranslatedString &name, uint04 idx, fltp04 progress) final override
Registers a progress source at a specific index.
void addInput(const StringView &s, uint04 idx) final override
Adds user input text associated with a specific input guard index.
void writeToFile(BinaryFile &file, uint01 minimum_log_level, CompressionMode mode=CompressionMode::e_default_compression)
Writes all log messages at or above the given level to a binary file.
void addStream(LogStream *stream, bool add_all) override
Adds a log stream to this manager and optionally to all child logs.
bool cancelRequestedIdx(uint04 idx) const final override
Checks whether cancellation has been requested for a specific index.
void logStartupInformation(const StringView &log) const
Logs system startup information such as environment and version details.
void addCancelGuard(const TranslatedString &name, uint04 idx) final override
Adds a cancel guard at a specific index.
void clearInputIdx(uint04 idx) final override
Clears the stored input text for a specific input guard index.
virtual void addMessage(uint04 id, const TranslatedString &, uint01=10) override
Adds a translated string message to all child logs.
uint04 addCancelGuard(const TranslatedString &name) final override
Adds a new cancel guard with the given name.
void addInput(const StringView &s) final override
Adds user input text to the default input guard.
void readFromFile(BinaryFile &file, uint08 version_number)
Reads log data from a binary file.
InfoPipe * getLog(const StringView &log_name) const
Retrieves the log pipe associated with the given name.
MoveMode
Defines how existing log data is handled when changing log paths.
Definition LogManager.h:21
@ e_move
Move existing log data to the new location.
Definition LogManager.h:22
@ e_copy
Copy existing log data to the new location.
Definition LogManager.h:23
@ e_ignore
Discard existing log data when switching locations.
Definition LogManager.h:24
fltp04 progressIdx(uint04 idx) const final override
Gets the progress percentage for a specific progress source.
uint04 addProgressSource(const TranslatedString &name, fltp04 progress) final override
Registers a new progress source with the given name and initial progress.
void removeProgressSource(uint04 idx) final override
Removes a progress source by index from all child logs.
void setProgressIdx(uint04 idx, fltp04 percent) final override
Sets the progress percentage for a specific progress source across all child logs.
virtual void addMessage(uint04 id, const StringView &, uint01=10) override
Adds a raw string message to all child logs.
void getInputIdx(String &s, uint04 idx, bool clear) final override
Retrieves user input text for a specific input guard index.
const Dictionary< String, InfoPipe * > & logs()
Returns a reference to the dictionary of all registered logs.
void addLog(const StringView &name, InfoPipe *info)
Registers a named log pipe with this manager.
void removeStream(LogStream *stream) override
Removes a log stream from this manager and all child logs.
void setDefaultAsciiLogPath(const File &file, MoveMode mode)
Sets the default file path for ASCII log output, optionally moving or copying existing data.
bool hasLog(const StringView &log_name) const
Checks whether a log with the given name exists in this manager.
void requestCancel() override
Requests cancellation of all ongoing operations across all child logs.
virtual void addMessages(uint04 id, const Buffer< LogMessage > &) override
Adds multiple log messages to all child logs in a batch.
InfoPipe * defaultLog() const
Retrieves the default log pipe named "DEFAULT".
Definition LogManager.h:42
void removeCancelGuard(uint04 idx) final override
Removes a cancel guard by index from all child logs.
A class that allows for specific log information to be conveyed to a InfoPipe object including inform...
Definition LogMessage.h:48
A listener that receives and processes log messages and progress updates from an InfoPipe.
Definition LogStream.h:49
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
CompressionMode
Forward declaration of the Module struct for module metadata.
Definition Compressor.h:17
@ e_default_compression
Uses a sensible default compression strategy.
Definition Compressor.h:19
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
@ file
The source file path associated with this object.
@ name
The display name of the object.