LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
config::Config Class Reference

#include <Config.hpp>

Collaboration diagram for config::Config:
Collaboration graph

Classes

struct  UpdateSettings
 

Public Member Functions

 Config ()
 
 Config (const Config &)=delete
 
Config & operator= (const Config &)=delete
 
 Config (Config &&)=delete
 
Config & operator= (Config &&)=delete
 
virtual ~Config ()=default
 
void LoadConfig ()
 Throws if the config file is not valid JSON (in-memory settings are kept).
 
void SaveConfig ()
 
void Reload ()
 Reload configuration from file.
 
const std::string & GetConfigFilePath () const
 
const std::string & GetAppLogPath () const
 
void SetConfigFilePath (const std::string &path)
 
void SetAppName (const std::string &name)
 
const std::vector< ColumnConfig > & GetColumns () const
 
std::vector< ColumnConfig > & GetMutableColumns ()
 
void GetPrintConfig () const
 
const FieldTranslator & GetFieldTranslator () const
 Get the field translator for value conversions.
 
FieldTranslator & GetMutableFieldTranslator ()
 Get mutable field translator for editing dictionary.
 
const std::string & GetDictionaryFilePath () const
 Get the dictionary file path.
 
void SetDictionaryFilePath (const std::string &path)
 Set the dictionary file path and reload dictionary.
 
const std::string & GetAppName () const
 
const Version::Version & GetConfigVersion () const
 Get the current config version.
 
void SetConfigVersion (const Version::Version &version)
 Set the config version.
 
std::filesystem::path GetDefaultAppPath ()
 Get the default application path.
 

Public Attributes

std::string appName {"LogViewer"}
 
std::vector< ColumnConfig > columns
 
std::vector< std::string > columnOrder
 
std::map< std::string, int > columnWidths
 
std::string logLevel {"debug"}
 
ColumnColorMap columnColors
 
ItemHighlightMap itemHighlights
 
std::string typeFilterField {}
 
std::string actorField {"actor"}
 
struct config::Config::UpdateSettings updates
 

Private Member Functions

const json & GetParserConfig (const json &j)
 
void ParseXmlConfig (const json &j)
 
void GetLoggingConfig (const json &j)
 
void GetFilterConfig (const json &j)
 
std::filesystem::path GetDefaultConfigPath ()
 
std::filesystem::path GetDefaultLogPath ()
 
void SetupLogPath ()
 
void GetColorConfig (const json &j)
 
json MergeConfigs (const json &userConfig, const json &defaultConfig)
 Merge new fields from default config into user config.
 

Private Attributes

std::string m_configFilePath {"config.json"}
 
std::string m_logPath {"log.txt"}
 
std::string m_dictionaryFilePath {"field_dictionary.json"}
 
FieldTranslator m_fieldTranslator
 
Version::Version m_configVersion
 
bool m_loadFailed {false}
 

Constructor & Destructor Documentation

◆ Config() [1/3]

config::Config::Config ( )
Here is the call graph for this function:

◆ Config() [2/3]

config::Config::Config ( const Config &  )
delete

◆ Config() [3/3]

config::Config::Config ( Config &&  )
delete

◆ ~Config()

virtual config::Config::~Config ( )
virtualdefault

Member Function Documentation

◆ GetAppLogPath()

const std::string & config::Config::GetAppLogPath ( ) const
Here is the caller graph for this function:

◆ GetAppName()

const std::string & config::Config::GetAppName ( ) const
inline

◆ GetColorConfig()

void config::Config::GetColorConfig ( const json &  j)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetColumns()

const std::vector< ColumnConfig > & config::Config::GetColumns ( ) const
Here is the caller graph for this function:

◆ GetConfigFilePath()

const std::string & config::Config::GetConfigFilePath ( ) const
Here is the caller graph for this function:

◆ GetConfigVersion()

const Version::Version & config::Config::GetConfigVersion ( ) const
inline

Get the current config version.

Returns
The version of the config file

◆ GetDefaultAppPath()

std::filesystem::path config::Config::GetDefaultAppPath ( )

Get the default application path.

Returns
Path to the default application directory
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDefaultConfigPath()

std::filesystem::path config::Config::GetDefaultConfigPath ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDefaultLogPath()

std::filesystem::path config::Config::GetDefaultLogPath ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDictionaryFilePath()

const std::string & config::Config::GetDictionaryFilePath ( ) const

Get the dictionary file path.

Returns
Path to the field dictionary file

◆ GetFieldTranslator()

const FieldTranslator & config::Config::GetFieldTranslator ( ) const

Get the field translator for value conversions.

Returns
Reference to the FieldTranslator instance
Here is the caller graph for this function:

◆ GetFilterConfig()

void config::Config::GetFilterConfig ( const json &  j)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetLoggingConfig()

void config::Config::GetLoggingConfig ( const json &  j)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMutableColumns()

std::vector< ColumnConfig > & config::Config::GetMutableColumns ( )
Here is the caller graph for this function:

◆ GetMutableFieldTranslator()

FieldTranslator & config::Config::GetMutableFieldTranslator ( )

Get mutable field translator for editing dictionary.

Returns
Mutable reference to the FieldTranslator instance
Here is the caller graph for this function:

◆ GetParserConfig()

const json & config::Config::GetParserConfig ( const json &  j)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPrintConfig()

void config::Config::GetPrintConfig ( ) const
Here is the call graph for this function:

◆ LoadConfig()

void config::Config::LoadConfig ( )

Throws if the config file is not valid JSON (in-memory settings are kept).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MergeConfigs()

json config::Config::MergeConfigs ( const json &  userConfig,
const json &  defaultConfig 
)
private

Merge new fields from default config into user config.

Parameters
userConfigUser's existing config
defaultConfigDefault config from application
Returns
Merged config with user values preserved and new fields added
Here is the caller graph for this function:

◆ operator=() [1/2]

Config & config::Config::operator= ( Config &&  )
delete

◆ operator=() [2/2]

Config & config::Config::operator= ( const Config &  )
delete

◆ ParseXmlConfig()

void config::Config::ParseXmlConfig ( const json &  j)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Reload()

void config::Config::Reload ( )

Reload configuration from file.

Convenience method that calls LoadConfig() to reload the configuration from the current config file path.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveConfig()

void config::Config::SaveConfig ( )

Replaces the file atomically. If the last load failed to parse it, the file is first copied to "<config>.bak" (nothing is written if that fails).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetAppName()

void config::Config::SetAppName ( const std::string &  name)

◆ SetConfigFilePath()

void config::Config::SetConfigFilePath ( const std::string &  path)

◆ SetConfigVersion()

void config::Config::SetConfigVersion ( const Version::Version &  version)
inline

Set the config version.

Parameters
versionThe version to set

◆ SetDictionaryFilePath()

void config::Config::SetDictionaryFilePath ( const std::string &  path)

Set the dictionary file path and reload dictionary.

Parameters
pathPath to the field dictionary file
Here is the call graph for this function:

◆ SetupLogPath()

void config::Config::SetupLogPath ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ actorField

std::string config::Config::actorField {"actor"}

◆ appName

std::string config::Config::appName {"LogViewer"}

◆ columnColors

ColumnColorMap config::Config::columnColors

◆ columnOrder

std::vector<std::string> config::Config::columnOrder

◆ columns

std::vector<ColumnConfig> config::Config::columns

◆ columnWidths

std::map<std::string, int> config::Config::columnWidths

◆ itemHighlights

ItemHighlightMap config::Config::itemHighlights

◆ logLevel

std::string config::Config::logLevel {"debug"}

◆ m_configFilePath

std::string config::Config::m_configFilePath {"config.json"}
private

◆ m_configVersion

Version::Version config::Config::m_configVersion
private

◆ m_dictionaryFilePath

std::string config::Config::m_dictionaryFilePath {"field_dictionary.json"}
private

◆ m_fieldTranslator

FieldTranslator config::Config::m_fieldTranslator
private

◆ m_loadFailed

bool config::Config::m_loadFailed {false}
private

◆ m_logPath

std::string config::Config::m_logPath {"log.txt"}
private

◆ typeFilterField

std::string config::Config::typeFilterField {}

◆ updates

struct config::Config::UpdateSettings config::Config::updates

The documentation for this class was generated from the following files: