summaryrefslogtreecommitdiff
path: root/Services
diff options
context:
space:
mode:
Diffstat (limited to 'Services')
-rw-r--r--Services/LoggerService.cs18
1 files changed, 3 insertions, 15 deletions
diff --git a/Services/LoggerService.cs b/Services/LoggerService.cs
index dd78e23..64eecb1 100644
--- a/Services/LoggerService.cs
+++ b/Services/LoggerService.cs
@@ -1,15 +1,11 @@
-using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
+// Singleton service.
namespace LibraryAPI.Services {
- public class LoggerService : IHostedService {
- private readonly IWebHostEnvironment env;
- private readonly string log_file = "Log.txt";
+ public class LoggerService : BaseService, IHostedService {
private Timer timer;
- public LoggerService(IWebHostEnvironment env) {
- this.env = env;
- }
+ public LoggerService(IWebHostEnvironment env) : base(env) { }
public Task StartAsync(CancellationToken cancel_token) {
timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(5));
@@ -25,13 +21,5 @@ namespace LibraryAPI.Services {
timer.Dispose();
return Task.CompletedTask;
}
-
- private void LogToFile(string message) {
- var path = $@"{env.ContentRootPath}/wwwroot/{log_file}";
-
- using (StreamWriter w = new StreamWriter(path, append: true)) {
- w.WriteLine(message);
- }
- }
}
}