mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-26 07:55:10 -07:00
Modify "WriteLine" with "_log".
When creating StartupLog, it configures itself.
This commit is contained in:
parent
7750fa50cf
commit
c915512c1a
2 changed files with 28 additions and 11 deletions
|
@ -20,7 +20,7 @@ namespace Ombi
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
private static string UrlArgs { get; set; }
|
private static string UrlArgs { get; set; }
|
||||||
private static StartupLog _log = new StartupLog();
|
private static StartupLog _log = new StartupLog(true);
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@ namespace Ombi
|
||||||
{
|
{
|
||||||
foreach (var e in err)
|
foreach (var e in err)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e);
|
_log.LogError(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ namespace Ombi
|
||||||
DeleteSchedules();
|
DeleteSchedules();
|
||||||
//CheckAndMigrate();
|
//CheckAndMigrate();
|
||||||
|
|
||||||
_log.Config();
|
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
services.ConfigureDatabases();
|
services.ConfigureDatabases();
|
||||||
using (var provider = services.BuildServiceProvider())
|
using (var provider = services.BuildServiceProvider())
|
||||||
|
@ -128,10 +127,8 @@ namespace Ombi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"We are running on {urlValue}");
|
_log.LogInformation($"We are running on {urlValue}");
|
||||||
|
|
||||||
CreateWebHostBuilder(args).Build().Run();
|
CreateWebHostBuilder(args).Build().Run();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (MySql.Data.MySqlClient.MySqlException e) when (e.SqlState.Equals("28000") || e.SqlState.Equals("42000"))
|
catch (MySql.Data.MySqlClient.MySqlException e) when (e.SqlState.Equals("28000") || e.SqlState.Equals("42000"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using ILogger = Serilog.ILogger;
|
using ILogger = Serilog.ILogger;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
|
using CommandLine;
|
||||||
|
|
||||||
namespace Ombi
|
namespace Ombi
|
||||||
{
|
{
|
||||||
|
@ -20,16 +20,24 @@ namespace Ombi
|
||||||
get { return Path.GetDirectoryName(Assembly.GetEntryAssembly().Location.Substring(0, Assembly.GetEntryAssembly().Location.IndexOf("bin\\"))); }
|
get { return Path.GetDirectoryName(Assembly.GetEntryAssembly().Location.Substring(0, Assembly.GetEntryAssembly().Location.IndexOf("bin\\"))); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public StartupLog()
|
private string ContentLogsPath
|
||||||
{
|
{
|
||||||
//this.config();
|
get { return Path.Combine(StoragePath.StoragePath.IsNullOrEmpty() ? this.ContentRootPath : StoragePath.StoragePath, "Logs"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public StartupLog(bool autoconf = false)
|
||||||
|
{
|
||||||
|
if (autoconf == true)
|
||||||
|
{
|
||||||
|
this.Config();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Config()
|
public void Config()
|
||||||
{
|
{
|
||||||
ILogger log_config = new LoggerConfiguration()
|
ILogger log_config = new LoggerConfiguration()
|
||||||
.MinimumLevel.Debug()
|
.MinimumLevel.Debug()
|
||||||
.WriteTo.RollingFile(Path.Combine(StoragePath.StoragePath.IsNullOrEmpty() ? this.ContentRootPath : StoragePath.StoragePath, "Logs", "startup-{Date}.txt"))
|
.WriteTo.RollingFile(Path.Combine(this.ContentLogsPath, "startup-{Date}.txt"))
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
Log.Logger = log_config;
|
Log.Logger = log_config;
|
||||||
}
|
}
|
||||||
|
@ -40,10 +48,22 @@ namespace Ombi
|
||||||
Log.Error(str);
|
Log.Error(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void LogError(Error e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
Log.Error(e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
public void LogInformation(string str)
|
public void LogInformation(string str)
|
||||||
{
|
{
|
||||||
Console.WriteLine(str);
|
Console.WriteLine(str);
|
||||||
Log.Information(str);
|
Log.Information(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LogVerbose(string str)
|
||||||
|
{
|
||||||
|
Console.WriteLine(str);
|
||||||
|
Log.Verbose(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue