summaryrefslogtreecommitdiff
path: root/Services
diff options
context:
space:
mode:
Diffstat (limited to 'Services')
-rw-r--r--Services/BaseService.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/Services/BaseService.cs b/Services/BaseService.cs
new file mode 100644
index 0000000..f48fe5f
--- /dev/null
+++ b/Services/BaseService.cs
@@ -0,0 +1,21 @@
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Hosting;
+
+namespace LibraryAPI.Services {
+ public abstract class BaseService {
+ private readonly IWebHostEnvironment env;
+ private readonly string log_file = "Log.txt";
+
+ public BaseService(IWebHostEnvironment env) {
+ this.env = env;
+ }
+
+ protected void LogToFile(string message) {
+ var path = $@"{env.ContentRootPath}/wwwroot/{log_file}";
+
+ using (StreamWriter w = new StreamWriter(path, append: true)) {
+ w.WriteLine(message);
+ }
+ }
+ }
+}