| | | 1 | | using CShells.Features; |
| | | 2 | | using Elsa.Diagnostics.StructuredLogs.Persistence.Relational.ShellFeatures; |
| | | 3 | | using Elsa.Diagnostics.StructuredLogs.Persistence.Sqlite.Extensions; |
| | | 4 | | using Elsa.PackageManifest.Generator.Hints; |
| | | 5 | | using JetBrains.Annotations; |
| | | 6 | | using Microsoft.Extensions.DependencyInjection; |
| | | 7 | | |
| | | 8 | | namespace Elsa.Diagnostics.StructuredLogs.Persistence.Sqlite.ShellFeatures; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Provides SQLite persistence for diagnostics structured logs. |
| | | 12 | | /// </summary> |
| | | 13 | | [ShellFeature( |
| | | 14 | | DisplayName = "SQLite Structured Log Persistence", |
| | | 15 | | Description = "Provides SQLite persistence for diagnostics structured logs", |
| | | 16 | | DependsOn = [typeof(StructuredLogRelationalPersistenceFeature)])] |
| | | 17 | | [UsedImplicitly] |
| | | 18 | | [ManifestInfrastructure("sqlite-database", "database", Reason = "Stores structured log records in SQLite.", Providers = |
| | | 19 | | public class SqliteStructuredLogPersistenceFeature : IShellFeature |
| | | 20 | | { |
| | | 21 | | [ManifestSetting( |
| | | 22 | | DisplayName = "Connection String", |
| | | 23 | | Description = "SQLite connection string used to store structured log records.", |
| | | 24 | | Category = "Persistence", |
| | | 25 | | Required = true, |
| | | 26 | | DefaultValue = "Data Source=elsa-structured-logs.db", |
| | | 27 | | Sensitive = true, |
| | | 28 | | RestartRequired = true)] |
| | 0 | 29 | | public string ConnectionString { get; set; } = "Data Source=elsa-structured-logs.db"; |
| | | 30 | | |
| | | 31 | | [ManifestSetting( |
| | | 32 | | DisplayName = "Run Migrations On Startup", |
| | | 33 | | Description = "Run structured log SQLite schema migrations when the application starts.", |
| | | 34 | | Category = "Persistence", |
| | | 35 | | DefaultValue = "true", |
| | | 36 | | RestartRequired = true)] |
| | 0 | 37 | | public bool RunMigrationsOnStartup { get; set; } = true; |
| | | 38 | | |
| | | 39 | | public void ConfigureServices(IServiceCollection services) |
| | | 40 | | { |
| | 0 | 41 | | services.AddSqliteStructuredLogPersistence(options => |
| | 0 | 42 | | { |
| | 0 | 43 | | options.ConnectionString = ConnectionString; |
| | 0 | 44 | | options.RunMigrationsOnStartup = RunMigrationsOnStartup; |
| | 0 | 45 | | }); |
| | 0 | 46 | | } |
| | | 47 | | } |