fix logger
continuous-integration/drone/push Build is passing Details

pagination
Tony Fages 1 year ago
parent d620088c63
commit d4eef3da9a

@ -15,3 +15,20 @@ info: 03/15/2024 16:59:30.063 RelationalEventId.CommandExecuted[20101] (Microsof
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title"
FROM "ArticleSet" AS "a"
info: 03/15/2024 17:08:29.557 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (6ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/15/2024 17:08:29.561 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: 03/15/2024 17:08:29.567 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "MigrationId", "ProductVersion"
FROM "__EFMigrationsHistory"
ORDER BY "MigrationId";
info: 03/15/2024 17:08:29.575 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
No migrations were applied. The database is already up to date.
info: 03/15/2024 17:08:33.305 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title"
FROM "ArticleSet" AS "a"

@ -7,14 +7,15 @@ namespace DbContextLib;
public class LibraryContext : DbContext
{
private static readonly StreamWriter LogFile = new StreamWriter("log.txt");
public LibraryContext()
: base()
{ }
{
}
public LibraryContext(DbContextOptions<LibraryContext> options)
: base(options)
{ }
{
}
@ -26,7 +27,11 @@ public class LibraryContext : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.LogTo(message => LogFile.WriteLine(message), LogLevel.Information);
optionsBuilder.LogTo(message =>
{
using var logFile = new StreamWriter("log.txt", append: true);
logFile.WriteLine(message);
}, LogLevel.Information);
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite($"Data Source=Entity_FrameWork.Article.db");
@ -161,16 +166,4 @@ public class LibraryContext : DbContext
);
*/
}
public override void Dispose()
{
base.Dispose();
LogFile.Dispose();
}
public override async ValueTask DisposeAsync()
{
await base.DisposeAsync();
await LogFile.DisposeAsync();
}
}
Loading…
Cancel
Save