summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2022-10-26 18:22:34 -0500
committerHombreLaser <sebastian-440@live.com>2022-10-26 18:22:34 -0500
commitaa37e431b0ec0c87d8f03c211aa73e1f186f1305 (patch)
tree3028e5cc119d093b204c3ba4089677a224446ccc
parent95b5b7431e853a65330d15612bb2949cacdbb11b (diff)
Añadida clase padre de servicios.
-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);
+ }
+ }
+ }
+}