The logging library for HexaEngine.
$ dotnet add package Hexa.NET.LoggingHexa.NET.Logging is a small, efficient logging framework for .NET applications. It provides a simple API for logging messages at various levels (e.g., error, warning, information). This framework is designed to be lightweight and easy to integrate into your existing .NET applications.
To install Hexa.NET.Logging, add the following package to your project:
dotnet add package Hexa.NET.Logging
Usage
Here is a basic example of how to use Hexa.NET.Logging in your application:
using Hexa.NET.Logging;
// Retrieve a logger for a specific category
var logger = LoggerFactory.GetLogger(nameof(MyClass));
// Store the logger in a static field/property for better performance
private static readonly ILogger _logger = LoggerFactory.GetLogger(nameof(MyClass));
// Log an error message
_logger.Error("Failed to create input layout, signature was null.");
// Log a warning message
_logger.Warning("This is a warning message.");
// Log an informational message
_logger.Info("This is an informational message.");
try
{
// Your code here
}
catch (Exception ex)
{
_logger.Log(ex); // Log the exception
}
// Log a message only if a condition is met
_logger.WarnIf(foo == bar, "This is a warning message.");
using Hexa.NET.Logging;
public class MyClass
{
private static readonly ILogger _logger = LoggerFactory.GetLogger(nameof(MyClass));
public void SomeMethod()
{
_logger.Info("This is an informational message.");
try
{
// Your code here
}
catch (Exception ex)
{
_logger.Log(ex); // Log the exception
}
}
}
Hexa.NET.Logging supports the following logging levels:
Contributions are welcome! Please fork the repository and submit a pull request with your changes. Ensure that your code follows the project's coding standards and includes appropriate tests.
Hexa.NET.Logging is licensed under the MIT License. See the LICENSE file for more details.