the logger class for ImGui with support for different types of logs, auto condensing for repeated messages and colouring of the logs also includes a debug console support with command history
More...
|
| class | MessageLog |
| | Represents a log message with its content, count of occurrences, and log type (info, warning, error). This class is used to store log messages in the ImGuiLogger, allowing for features like message aggregation (counting repeated messages) and categorization by log type for filtering and display purposes in the debug console. Each MessageLog instance contains the actual log message, how many times it has been logged (for repeated messages), and the type of log to determine how it should be displayed in the UI. More...
|
| class | Command |
| | Represents a console command with its command path, command name, and parameters. This class is used to store commands that are entered by the user in the debug console, allowing them to be queued for execution. Each Command instance contains the full path of the command (split into parts), the specific command to execute, and any parameters that were provided with the command. This structure enables the CommandRegistry to look up and invoke the correct method based on the command path and name when processing user input from the debug console. More...
|
|
| enum | LogTypes { Info
, Warning
, Error
} |
|
| void | RegisterEnvVar (string name, Func< string > resolver) |
| | Registers an environment variable that can be used in console commands. The name parameter specifies the name of the environment variable, which can be referenced in commands using the syntax $VariableName. The resolver parameter is a function that returns the current value of the environment variable as a string. When a command is processed, any occurrences of $VariableName will be replaced with the value returned by the corresponding resolver function. This allows for dynamic values to be used in console commands, such as referencing the current active mesh or other runtime information without needing to hardcode values into commands. By using environment variables, users can create more flexible and powerful commands that adapt to the current state of the application.
|
|
void | AddLog (string message, LogTypes type=LogTypes.Info) |
| void | AddCommand (string command) |
| | Adds a console command to the command queue for later processing. The command string is trimmed and checked for validity before being added to the queue. If the command is empty or consists only of whitespace, it is ignored. The method also resolves any environment variables in the command string before parsing it into its components (command path, command name, and parameters). The parsed command is then enqueued for execution, and a log message is added to indicate that the command has been queued. This allows users to enter commands in the debug console, which can then be processed asynchronously in the main game loop without blocking the UI or requiring immediate execution.
|
| bool | TryDequeueCommand (out Command command) |
| | attempts to dequeue a command from the command queue if the command one is avoable it is returned through out
|
| void | DrawLogs (ref bool openWindow) |
| | draws all logs in ImGui with options to filter by log type, auto scroll and wrap text.
|
| string | GetLogsAsString () |
| | converts all of the logs to a string to be saved to a log file
|
| void | SaveLogsToFile (string filePath) |
| | saves logs to a file in the specified file path
|
|
|
bool | autoScrollLogs = true |
| | deterimines on wether it should auto scroll the logs to the bottom when a new log is added this is toggled by the user
|
|
bool | wrapText = true |
| | deterimes wether the log messages should wrap in the log display
|
|
bool | supportDebugConsole = true |
| | a toggle for if the debug console is supported and should be displayed
|
|
|
bool | HasPendingCommands [get] |
| | returns true if there are pending commands in the command queue
|
|
| string | ResolveEnvVars (string command) |
| | replaces the text of any environment variables in the command string with their current values by using regular expressions to find occurrences of $VariableName and replacing them with the output of the corresponding resolver function from the _envVars dictionary
|
|
|
readonly Queue< MessageLog > | _logs = new() |
| | the queue of log messages that have been added and for display in the imgui fiole
|
|
readonly Queue< Command > | _commands = new() |
| | the queue of console commands that have been added but not yet processed for execution
|
|
string | _commandInput = "" |
| | the raw text inputed by the user in the debug console input field
|
|
List< string > | _logStringHistory = new() |
| | the proccessed log messages that are ready for saving to a file
|
|
readonly Dictionary< string, Func< string > > | _envVars = new() |
| readonly List< string > | _commandHistory = new() |
| | saves the text inputed by the user for comand history if the user wants to recall it later with arrow keys
|
|
int | _historyIndex = -1 |
| | where the user is in the command history
|
|
string | _savedInput = "" |
| readonly Dictionary< LogTypes, bool > | _logTypeVisibility |
| | Dictionary to track the visibility of different log types (info, warning, error) in the debug console. This allows users to filter which types of log messages they want to see by toggling the corresponding checkboxes in the UI. Each log type can be shown or hidden based on the user's preference, making it easier to focus on specific types of messages when debugging. For example, a user might choose to hide info messages and only show warnings and errors to quickly identify issues without being overwhelmed by less critical information.
|
the logger class for ImGui with support for different types of logs, auto condensing for repeated messages and colouring of the logs also includes a debug console support with command history
◆ AddCommand()
| void PhysicsCSAlevlProject.ImGuiLogger.AddCommand |
( |
string | command | ) |
|
|
inline |
Adds a console command to the command queue for later processing. The command string is trimmed and checked for validity before being added to the queue. If the command is empty or consists only of whitespace, it is ignored. The method also resolves any environment variables in the command string before parsing it into its components (command path, command name, and parameters). The parsed command is then enqueued for execution, and a log message is added to indicate that the command has been queued. This allows users to enter commands in the debug console, which can then be processed asynchronously in the main game loop without blocking the UI or requiring immediate execution.
- Parameters
-
◆ DrawLogs()
| void PhysicsCSAlevlProject.ImGuiLogger.DrawLogs |
( |
ref bool | openWindow | ) |
|
|
inline |
draws all logs in ImGui with options to filter by log type, auto scroll and wrap text.
- Parameters
-
◆ GetLogsAsString()
| string PhysicsCSAlevlProject.ImGuiLogger.GetLogsAsString |
( |
| ) |
|
|
inline |
converts all of the logs to a string to be saved to a log file
- Returns
◆ RegisterEnvVar()
| void PhysicsCSAlevlProject.ImGuiLogger.RegisterEnvVar |
( |
string | name, |
|
|
Func< string > | resolver ) |
|
inline |
Registers an environment variable that can be used in console commands. The name parameter specifies the name of the environment variable, which can be referenced in commands using the syntax $VariableName. The resolver parameter is a function that returns the current value of the environment variable as a string. When a command is processed, any occurrences of $VariableName will be replaced with the value returned by the corresponding resolver function. This allows for dynamic values to be used in console commands, such as referencing the current active mesh or other runtime information without needing to hardcode values into commands. By using environment variables, users can create more flexible and powerful commands that adapt to the current state of the application.
- Parameters
-
◆ ResolveEnvVars()
| string PhysicsCSAlevlProject.ImGuiLogger.ResolveEnvVars |
( |
string | command | ) |
|
|
inlineprivate |
replaces the text of any environment variables in the command string with their current values by using regular expressions to find occurrences of $VariableName and replacing them with the output of the corresponding resolver function from the _envVars dictionary
- Parameters
-
- Returns
◆ SaveLogsToFile()
| void PhysicsCSAlevlProject.ImGuiLogger.SaveLogsToFile |
( |
string | filePath | ) |
|
|
inline |
saves logs to a file in the specified file path
- Parameters
-
◆ TryDequeueCommand()
| bool PhysicsCSAlevlProject.ImGuiLogger.TryDequeueCommand |
( |
out Command | command | ) |
|
|
inline |
attempts to dequeue a command from the command queue if the command one is avoable it is returned through out
- Parameters
-
- Returns
◆ _commandHistory
| readonly List<string> PhysicsCSAlevlProject.ImGuiLogger._commandHistory = new() |
|
private |
saves the text inputed by the user for comand history if the user wants to recall it later with arrow keys
/
◆ _logTypeVisibility
| readonly Dictionary<LogTypes, bool> PhysicsCSAlevlProject.ImGuiLogger._logTypeVisibility |
|
private |
Initial value: = new Dictionary<LogTypes, bool>
{
{ LogTypes.Info, true },
{ LogTypes.Warning, true },
{ LogTypes.Error, true },
}
Dictionary to track the visibility of different log types (info, warning, error) in the debug console. This allows users to filter which types of log messages they want to see by toggling the corresponding checkboxes in the UI. Each log type can be shown or hidden based on the user's preference, making it easier to focus on specific types of messages when debugging. For example, a user might choose to hide info messages and only show warnings and errors to quickly identify issues without being overwhelmed by less critical information.
The documentation for this class was generated from the following file:
- PhysicsCSAlevlProject/Game1.DebugCommands.cs