CerbiStream.GovernanceAnalyzer 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package CerbiStream.GovernanceAnalyzer --version 1.0.2
                    
NuGet\Install-Package CerbiStream.GovernanceAnalyzer -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CerbiStream.GovernanceAnalyzer" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CerbiStream.GovernanceAnalyzer" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="CerbiStream.GovernanceAnalyzer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CerbiStream.GovernanceAnalyzer --version 1.0.2
                    
#r "nuget: CerbiStream.GovernanceAnalyzer, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=CerbiStream.GovernanceAnalyzer&version=1.0.2
                    
Install CerbiStream.GovernanceAnalyzer as a Cake Addin
#tool nuget:?package=CerbiStream.GovernanceAnalyzer&version=1.0.2
                    
Install CerbiStream.GovernanceAnalyzer as a Cake Tool

CerbiStream Governance Analyzer

CerbiStream-GovernanceAnalyzer is a Roslyn-based static analysis tool designed to enforce structured logging standards within applications using CerbiStream. It ensures that log messages adhere to governance rules defined in a JSON configuration, reducing runtime validation overhead and improving the developer experience.

🔥 Why Use CerbiStream-GovernanceAnalyzer?

  • 🚀 Compile-Time Log Validation – Prevents misformatted logs before deployment.
  • 📊 Structured Logging Enforcement – Ensures consistent log structures across teams.
  • 🔧 Customizable Rules via JSON – Organizations can define mandatory log fields.
  • 🔄 Seamless Integration with CerbiStream – Works alongside CerbiStream for log governance.
  • ⚡ Lightweight & Fast – Runs at build time, avoiding runtime performance impact.
  • ♻️ Dynamic Governance Reloading – Governance rules auto-reload if the JSON file is updated.

📦 Installation

To add CerbiStream-GovernanceAnalyzer to your project, install it via NuGet:

dotnet add package CerbiStream.GovernanceAnalyzer

📌 How It Works 1️ Governance Rules via JSON Define required and optional logging fields in a cerbi_governance.json file.


{
  "LoggingProfiles": {
    "API": {
      "RequiredFields": ["Timestamp", "LogLevel", "Message", "ApplicationId"],
      "OptionalFields": ["UserId", "TransactionId"],
      "AllowedLevels": ["Information", "Warning", "Error"],
      "EnforcementLevel": "Warning"
    },
    "SecurityLog": {
      "RequiredFields": ["UserId", "IPAddress"],
      "OptionalFields": ["DeviceType"],
      "AllowedLevels": ["Error", "Critical"],
      "EnforcementLevel": "Error"
    }
  }
}

2️ Static Analysis at Build-Time The Governance Analyzer checks log statements during compilation:

✅ Valid Log (meets governance rules):

logger.LogInformation("User login successful | UserId: {UserId}, Timestamp: {Timestamp}", userId, DateTime.UtcNow);

❌ Invalid Log (missing required fields):

logger.LogInformation("User login successful"); // ❌ Missing required metadata

Result: The build will fail or show a warning, depending on EnforcementLevel in cerbi_governance.json.

3️ Enforce or Warn Mode Choose whether governance rules should fail the build (Error Mode) or just warn developers (Warning Mode). This can be configured in cerbi_governance.json per logging profile.

🛠️ Configuration Options

Option Type Description
RequiredFields string[] Fields that must be present in logs.
OptionalFields string[] Fields that are recommended but not mandatory.
AllowedLevels string[] Defines permissible log levels (e.g., Information, Warning).
EnforcementLevel string Can be Error (fail build) or Warning (notify devs).
ReloadOnChange bool If true, the analyzer reloads governance rules dynamically.

📖 Example Usage 1️ Enabling Governance in CerbiStream In your Program.cs:

var serviceProvider = new ServiceCollection()
    .AddLogging(builder =>
    {
        builder.AddCerbiStream(options =>
        {
            options.EnableGovernance();
        });
    })
    .BuildServiceProvider();

2️ Running the Governance Analyzer The analyzer automatically runs during the build process. If any logs do not meet governance standards, you’ll see build errors or warnings.

3️ Dynamic Governance Reloading

Governance rules auto-reload when the cerbi_governance.json file is updated.

No need to restart the application to apply changes.

🚀 Future Enhancements

  • 🔄 Integration with CI/CD Pipelines – Enforce logging rules in GitHub Actions, Azure DevOps, and Jenkins.
  • 📊 Dashboard for Governance Management – UI to dynamically modify logging rules.
  • 🔀 Multi-Project Support – Apply governance rules across microservices.
  • 🧠 AI-Powered Log Insights – Use machine learning to analyze log patterns and recommend governance improvements.

📜 License

CerbiStream-GovernanceAnalyzer is open-source under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 112 3/28/2025
1.0.4 447 3/26/2025
1.0.3 139 3/23/2025
1.0.2 135 3/20/2025
1.0.1 191 3/19/2025
1.0.0 134 3/19/2025