CerbiStream.GovernanceAnalyzer
1.0.2
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
<PackageReference Include="CerbiStream.GovernanceAnalyzer" Version="1.0.2" />
<PackageVersion Include="CerbiStream.GovernanceAnalyzer" Version="1.0.2" />
<PackageReference Include="CerbiStream.GovernanceAnalyzer" />
paket add CerbiStream.GovernanceAnalyzer --version 1.0.2
#r "nuget: CerbiStream.GovernanceAnalyzer, 1.0.2"
#addin nuget:?package=CerbiStream.GovernanceAnalyzer&version=1.0.2
#tool nuget:?package=CerbiStream.GovernanceAnalyzer&version=1.0.2
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 | Versions 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. |
-
net8.0
- Microsoft.CodeAnalysis.CSharp (>= 4.13.0)
- Microsoft.CodeAnalysis.Workspaces.Common (>= 4.13.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.