-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from TheHeadmaster/1.2.1-alpha
Merge 1.2.1-alpha
- Loading branch information
Showing
141 changed files
with
10,325 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Librarium.Core; | ||
using MethodBoundaryAspect.Fody.Attributes; | ||
using Serilog; | ||
|
||
namespace Quartz.Core.Diagnostics | ||
{ | ||
/// <summary> | ||
/// Logs a message to the sink pool before and/or after a method call. | ||
/// </summary> | ||
public sealed class LogAttribute : OnMethodBoundaryAspect | ||
{ | ||
/// <summary> | ||
/// The message to log before the method is called. | ||
/// </summary> | ||
public string EntryMessage { get; private set; } | ||
|
||
/// <summary> | ||
/// The message to log if the method throws an exception. | ||
/// </summary> | ||
public string ExceptionMessage { get; private set; } | ||
|
||
/// <summary> | ||
/// The message to log after a method is called. | ||
/// </summary> | ||
public string ExitMessage { get; private set; } | ||
|
||
/// <summary> | ||
/// Determines whether the thrown exception should be considered a fatal exception. | ||
/// </summary> | ||
public bool IsExceptionFatal { get; private set; } | ||
|
||
/// <summary> | ||
/// Logs a message to the sink pool before and/or after a method call. | ||
/// </summary> | ||
/// <param name="entryMessage"> | ||
/// The message to log before the method is called. | ||
/// </param> | ||
/// <param name="exitMessage"> | ||
/// The message to log after a method is completed. | ||
/// </param> | ||
/// <param name="exceptionMessage"> | ||
/// The message to log in the event that the method throws an exception. | ||
/// </param> | ||
/// <param name="IsExceptionFatal"> | ||
/// Tells the logger that any exception thrown in this method is considered a fatal | ||
/// exception, and should be logged as such. | ||
/// </param> | ||
public LogAttribute(string entryMessage = "", string exitMessage = "", string exceptionMessage = "", bool IsExceptionFatal = false) | ||
{ | ||
this.EntryMessage = entryMessage; | ||
this.ExitMessage = exitMessage; | ||
this.ExceptionMessage = exceptionMessage; | ||
this.IsExceptionFatal = IsExceptionFatal; | ||
} | ||
|
||
public override void OnEntry(MethodExecutionArgs args) | ||
{ | ||
if (!this.EntryMessage.IsNullOrWhiteSpace()) | ||
{ | ||
Log.Information("{EntryMessage}", this.EntryMessage); | ||
} | ||
} | ||
|
||
public override void OnException(MethodExecutionArgs args) | ||
{ | ||
if (this.IsExceptionFatal) | ||
{ | ||
if (!this.ExceptionMessage.IsNullOrWhiteSpace()) | ||
{ | ||
Log.Fatal(args.Exception, ""); | ||
} | ||
else | ||
{ | ||
Log.Fatal(args.Exception, "{Exception}", this.ExceptionMessage); | ||
} | ||
} | ||
else | ||
{ | ||
if (!this.ExceptionMessage.IsNullOrWhiteSpace()) | ||
{ | ||
Log.Error(args.Exception, ""); | ||
} | ||
else | ||
{ | ||
Log.Error(args.Exception, "{Exception}", this.ExceptionMessage); | ||
} | ||
} | ||
} | ||
|
||
public override void OnExit(MethodExecutionArgs args) | ||
{ | ||
if (args.ReturnValue is Task t) | ||
{ | ||
t.ContinueWith(task => | ||
{ | ||
if (!this.ExitMessage.IsNullOrWhiteSpace()) | ||
{ | ||
Log.Information("{ExitMessage}", this.ExitMessage); | ||
} | ||
}); | ||
} | ||
else | ||
{ | ||
if (!this.ExitMessage.IsNullOrWhiteSpace()) | ||
{ | ||
Log.Information("{ExitMessage}", this.ExitMessage); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using Librarium.Core; | ||
using Serilog; | ||
using Serilog.Formatting.Compact; | ||
using Serilog.Sinks.SystemConsole.Themes; | ||
|
||
namespace Quartz.Core.Diagnostics | ||
{ | ||
/// <summary> | ||
/// Manages logging setup and functions. | ||
/// </summary> | ||
public static class LogManager | ||
{ | ||
private static string logPath = ""; | ||
|
||
/// <summary> | ||
/// Sets up the color theme for ESDashboard. | ||
/// </summary> | ||
private static AnsiConsoleTheme QuartzTheme { get; } = new AnsiConsoleTheme( | ||
new Dictionary<ConsoleThemeStyle, string> | ||
{ | ||
[ConsoleThemeStyle.Text] = "\x1b[38;5;0229m", | ||
[ConsoleThemeStyle.SecondaryText] = "\x1b[38;5;0246m", | ||
[ConsoleThemeStyle.TertiaryText] = "\x1b[38;5;0242m", | ||
[ConsoleThemeStyle.Invalid] = "\x1b[33;1m", | ||
[ConsoleThemeStyle.Null] = "\x1b[38;5;0038m", | ||
[ConsoleThemeStyle.Name] = "\x1b[38;5;0081m", | ||
[ConsoleThemeStyle.String] = "\x1b[38;5;0216m", | ||
[ConsoleThemeStyle.Number] = "\x1b[38;5;151m", | ||
[ConsoleThemeStyle.Boolean] = "\x1b[38;5;0038m", | ||
[ConsoleThemeStyle.Scalar] = "\x1b[38;5;0079m", | ||
[ConsoleThemeStyle.LevelVerbose] = "\x1b[197m", | ||
[ConsoleThemeStyle.LevelDebug] = "\x1b[089m", | ||
[ConsoleThemeStyle.LevelInformation] = "\x1b[37;163m", | ||
[ConsoleThemeStyle.LevelWarning] = "\x1b[38;5;0226m", | ||
[ConsoleThemeStyle.LevelError] = "\x1b[38;5;0160m", | ||
[ConsoleThemeStyle.LevelFatal] = "\x1b[38;5;0124m", | ||
}); | ||
|
||
/// <summary> | ||
/// Initializes the log manager. Logging sinks are set up here. | ||
/// </summary> | ||
public static void Initialize() | ||
{ | ||
if (logPath.IsNullOrWhiteSpace()) | ||
{ | ||
DateTime dt = DateTime.UtcNow; | ||
string filename = $"{dt.Month}-{dt.Day}-{dt.Year} {dt.Hour}-{dt.Minute}-{dt.Second}"; | ||
logPath = Path.Combine(AppMeta.AppDataDirectory, "Quartz", "Logs", $"{filename}.json"); | ||
} | ||
if (!Directory.Exists(Path.Combine(AppMeta.AppDataDirectory, "Quartz", "Logs"))) | ||
{ | ||
Directory.CreateDirectory(Path.Combine(AppMeta.AppDataDirectory, "Quartz", "Logs")); | ||
} | ||
|
||
Log.Logger = new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {Message:lj}{NewLine}{Exception}", theme: QuartzTheme) | ||
.WriteTo.Debug(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {Message:lj}{NewLine}{Exception}") | ||
.WriteTo.Seq("http://localhost:5341") | ||
.WriteTo.File(new CompactJsonFormatter(), logPath) | ||
.CreateLogger(); | ||
|
||
Log.Information("Logging to the output tab."); | ||
Log.Information("Logging to Seq. Open http://localhost:5341 for more details."); | ||
Log.Information("Logging to compact json file. Check the 'Logs' folder."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | ||
<ReactiveUI /> | ||
<MethodBoundaryAspect /> | ||
<PropertyChanged /> | ||
</Weavers> |
Oops, something went wrong.