HuntGlitch C# Project

HuntGlitch is a C# library built on .NET Core 2.1 designed to detect and analyze visual glitches within applications or graphical outputs. This package provides tools to identify potential rendering issues, screen tearing, and other visual anomalies.

To use HuntGlitch in your .NET Core 2.1 project, you can install it via NuGet Package Manager.

Using NuGet Package Manager Console:

Install-Package HuntGlitch

Using .NET CLI:

dotnet add package HuntGlitch

Prerequisites:

  • .NET Core 2.1 SDK or later installed
  • A compatible IDE like Visual Studio or a text editor

Usage

To run the application, execute the following command:

dotnet run

Step 1: Register a New Account

Step 2: Create a New Project

  • 1. Go to All Projects.
  • Step 2 Image 1
  • 2. Click “Add Project” and enter details.
  • Step 2 Image 2
  • 3. Enter the "Project Name" and "Deliverables" in the respective fields.
  • 4. Click "Save" to create the project.

Step 3: View Your Project

1. Go back to the project list, and you will see your newly created project.

Project Preview

2. Click on your project to preview log information.

Step 4: Obtain Your Keys

  • ProjectKey: Your unique project identifier.
  • DeliverableKey: Your unique deliverable identifier.

Step 5: Configure Your Application

Add the following in your appsettings.json:

{
    "HuntGlitchSettings": {
        "ProjectKey": "YOUR_PROJECT_KEY",
        "DeliverableKey": "YOUR_DELIVERABLE_KEY"
    }
}

Usage

After installing and configuring the package, you can start using the HuntGlitch library in your C# code. Here's a basic example of how to use it:

Note: Some of the code is conceptual and may need to be adjusted to fit your project's structure.

Step 6: Register HuntGlitch Services

To integrate HuntGlitch effectively, you need to register its services within your application's Startup.cs (or Program.cs in .NET 6+). Add HuntGlitch services to the service collection: // In Startup.cs (ConfigureServices) or Program.cs // Bind app-settings to your AppSettings class (if applicable)
builder.Services.AddHuntGlitch(builder.Configuration);

Sample DI in Controller

//This is the sample data form which you can use in your controller file.
private readonly IHuntGlitchLog _huntGlitchLogs;

//Constructor
public TestController(IHuntGlitchLog huntGlitchLogs)
{
    _huntGlitchLogs = huntGlitchLogs;
}

Logging Examples

DebugAsync
//Log debug without additional data or tags
await_huntGlitchLogs.DebugAsync();
//Log debug with additional data
await _huntGlitchLogs.DebugAsync(additionalData);
//Log debug with tag data
await _huntGlitchLogs.DebugAsync(tagData);
//Log debug with additional data and tag data
await _huntGlitchLogs.DebugAsync(additionalData, tagData);
WarningAsync
await _huntGlitchLogs.WarningAsync();
//Log warning with additional data
await _huntGlitchLogs.WarningAsync(additionalData);
//Log warning with tag data
await _huntGlitchLogs.WarningAsync(tagData);
//Log warning with additional data and tag data
await _huntGlitchLogs.WarningAsync(additionalData, tagData);
NoticeAsync
await _huntGlitchLogs.NoticeAsync();
//Log notice with additional data
await _huntGlitchLogs.NoticeAsync(additionalData);
//Log notice with tag data
await _huntGlitchLogs.NoticeAsync(tagData);
//Log notice with additional data and tag data
await _huntGlitchLogs.NoticeAsync(additionalData, tagData);
InformationAsync
await _huntGlitchLogs.InfoAsync();
//Log information with additional data
await _huntGlitchLogs.InfoAsync(additionalData);
//Log information with tag data
await _huntGlitchLogs.InfoAsync(tagData);
//Log information with additional data and tag data
await _huntGlitchLogs.InfoAsync(additionalData, tagData);
ErrorAsync
//Log error with exception only
await _huntGlitchLogs.ErrorAsync(exception);
//Log error with exception and additional data
await _huntGlitchLogs.ErrorAsync(exception, additionalData);
//Log error with exception and tag data
await _huntGlitchLogs.ErrorAsync(exception, tagData);
//Log error with exception, additional data, and tag data
await _huntGlitchLogs.ErrorAsync(exception, additionalData, tagData);
Example of Additional and Tag Data
private static Dictionary<string, object> additionalData = new Dictionary<string, object>() {
  { "user_data", new { name = "John", id = 1 } },
  { "order_data", new { order_id = "001" } },
  { "error_data", new { eventId = "002" } }
};

private static Dictionary<string, string> tagData = new Dictionary<string, object>() {
  { "environment", "production" },
  { "module", "authentication" },
  { "feature", "login" },
  { "logger", "csharp" },
  { "csharp-version", Environment.Version.ToString() }
};

Extracted Information

HuntGlitch extracts various pieces of information from the HTTP context to provide detailed logs. This includes:

  • Request Body
  • Request Headers
  • Request Method Type
  • Request URL

Additionally, it extracts:

  • Browser Name and Version (from the User-Agent header)
  • Operating System (from the sec-ch-ua-platform header)

Exception Handling

HuntGlitch captures detailed error information, including:

  • Error Message
  • File Name
  • Line Number
  • Error Code (hash)
  • Exception Class & Method

Important Notes

  • Refer to the official documentation or the source code in the GitHub repository for detailed information on the available classes, methods, and properties within the HuntGlitch library.
  • Ensure your project targets .NET Core 2.1 or a compatible framework.
  • Replace the conceptual code examples with actual implementation using the real HuntGlitch API.

Contact

For questions or issues, please open an issue on the GitHub repository.