summaryrefslogtreecommitdiff
path: root/Services/BaseService.cs
blob: f48fe5f4effd4f8d3bdb685059cc48867e388692 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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);
	    }
	}
    }
}