refactor(Dalamud): switch to file-scoped namespaces

This commit is contained in:
goat 2021-11-17 19:42:32 +01:00
parent 13cf3d93dc
commit b5f34c3199
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
325 changed files with 45878 additions and 46218 deletions

View file

@ -1,124 +1,123 @@
using System;
namespace Dalamud.Logging.Internal
namespace Dalamud.Logging.Internal;
/// <summary>
/// Class offering various methods to allow for logging in Dalamud modules.
/// </summary>
internal class ModuleLog
{
private readonly string moduleName;
/// <summary>
/// Class offering various methods to allow for logging in Dalamud modules.
/// Initializes a new instance of the <see cref="ModuleLog"/> class.
/// This class can be used to prefix logging messages with a Dalamud module name prefix. For example, "[PLUGINR] ...".
/// </summary>
internal class ModuleLog
/// <param name="moduleName">The module name.</param>
public ModuleLog(string moduleName)
{
private readonly string moduleName;
/// <summary>
/// Initializes a new instance of the <see cref="ModuleLog"/> class.
/// This class can be used to prefix logging messages with a Dalamud module name prefix. For example, "[PLUGINR] ...".
/// </summary>
/// <param name="moduleName">The module name.</param>
public ModuleLog(string moduleName)
{
this.moduleName = moduleName;
}
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Verbose(string messageTemplate, params object[] values)
=> Serilog.Log.Verbose($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Verbose(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Verbose(exception, $"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Debug(string messageTemplate, params object[] values)
=> Serilog.Log.Debug($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Debug(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Debug(exception, $"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Information(string messageTemplate, params object[] values)
=> Serilog.Log.Information($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Information(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Information(exception, $"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Warning(string messageTemplate, params object[] values)
=> Serilog.Log.Warning($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Warning(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Warning(exception, $"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Error(string messageTemplate, params object[] values)
=> Serilog.Log.Error($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Error(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Error(exception, $"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Fatal(string messageTemplate, params object[] values)
=> Serilog.Log.Fatal($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Fatal(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Fatal(exception, $"[{this.moduleName}] {messageTemplate}", values);
this.moduleName = moduleName;
}
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Verbose(string messageTemplate, params object[] values)
=> Serilog.Log.Verbose($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Verbose(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Verbose(exception, $"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Debug(string messageTemplate, params object[] values)
=> Serilog.Log.Debug($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Debug(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Debug(exception, $"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Information(string messageTemplate, params object[] values)
=> Serilog.Log.Information($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Information(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Information(exception, $"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Warning(string messageTemplate, params object[] values)
=> Serilog.Log.Warning($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Warning(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Warning(exception, $"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Error(string messageTemplate, params object[] values)
=> Serilog.Log.Error($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Error(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Error(exception, $"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Fatal(string messageTemplate, params object[] values)
=> Serilog.Log.Fatal($"[{this.moduleName}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public void Fatal(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Fatal(exception, $"[{this.moduleName}] {messageTemplate}", values);
}

View file

@ -3,49 +3,48 @@ using System;
using Serilog.Core;
using Serilog.Events;
namespace Dalamud.Logging.Internal
namespace Dalamud.Logging.Internal;
/// <summary>
/// Serilog event sink.
/// </summary>
internal class SerilogEventSink : ILogEventSink
{
private static SerilogEventSink instance;
private readonly IFormatProvider formatProvider;
/// <summary>
/// Serilog event sink.
/// Initializes a new instance of the <see cref="SerilogEventSink"/> class.
/// </summary>
internal class SerilogEventSink : ILogEventSink
/// <param name="formatProvider">Logging format provider.</param>
private SerilogEventSink(IFormatProvider formatProvider)
{
private static SerilogEventSink instance;
private readonly IFormatProvider formatProvider;
this.formatProvider = formatProvider;
}
/// <summary>
/// Initializes a new instance of the <see cref="SerilogEventSink"/> class.
/// </summary>
/// <param name="formatProvider">Logging format provider.</param>
private SerilogEventSink(IFormatProvider formatProvider)
/// <summary>
/// Event on a log line being emitted.
/// </summary>
public event EventHandler<(string Line, LogEventLevel Level, DateTimeOffset TimeStamp, Exception? Exception)>? LogLine;
/// <summary>
/// Gets the default instance.
/// </summary>
public static SerilogEventSink Instance => instance ??= new SerilogEventSink(null);
/// <summary>
/// Emit a log event.
/// </summary>
/// <param name="logEvent">Log event to be emitted.</param>
public void Emit(LogEvent logEvent)
{
var message = logEvent.RenderMessage(this.formatProvider);
if (logEvent.Exception != null)
{
this.formatProvider = formatProvider;
message += "\n" + logEvent.Exception;
}
/// <summary>
/// Event on a log line being emitted.
/// </summary>
public event EventHandler<(string Line, LogEventLevel Level, DateTimeOffset TimeStamp, Exception? Exception)>? LogLine;
/// <summary>
/// Gets the default instance.
/// </summary>
public static SerilogEventSink Instance => instance ??= new SerilogEventSink(null);
/// <summary>
/// Emit a log event.
/// </summary>
/// <param name="logEvent">Log event to be emitted.</param>
public void Emit(LogEvent logEvent)
{
var message = logEvent.RenderMessage(this.formatProvider);
if (logEvent.Exception != null)
{
message += "\n" + logEvent.Exception;
}
this.LogLine?.Invoke(this, (message, logEvent.Level, logEvent.Timestamp, logEvent.Exception));
}
this.LogLine?.Invoke(this, (message, logEvent.Level, logEvent.Timestamp, logEvent.Exception));
}
}

View file

@ -8,223 +8,222 @@ using System.Threading.Tasks;
using Dalamud.Game;
using Serilog;
namespace Dalamud.Logging.Internal
namespace Dalamud.Logging.Internal;
/// <summary>
/// Class responsible for tracking asynchronous tasks.
/// </summary>
internal class TaskTracker : IDisposable
{
private static readonly ModuleLog Log = new("TT");
private static readonly List<TaskInfo> TrackedTasksInternal = new();
private static readonly ConcurrentQueue<TaskInfo> NewlyCreatedTasks = new();
private static bool clearRequested = false;
private MonoMod.RuntimeDetour.Hook? scheduleAndStartHook;
/// <summary>
/// Class responsible for tracking asynchronous tasks.
/// Initializes a new instance of the <see cref="TaskTracker"/> class.
/// </summary>
internal class TaskTracker : IDisposable
public TaskTracker()
{
private static readonly ModuleLog Log = new("TT");
private static readonly List<TaskInfo> TrackedTasksInternal = new();
private static readonly ConcurrentQueue<TaskInfo> NewlyCreatedTasks = new();
private static bool clearRequested = false;
this.ApplyPatch();
private MonoMod.RuntimeDetour.Hook? scheduleAndStartHook;
var framework = Service<Framework>.Get();
framework.Update += this.FrameworkOnUpdate;
}
/// <summary>
/// Initializes a new instance of the <see cref="TaskTracker"/> class.
/// </summary>
public TaskTracker()
/// <summary>
/// Gets a read-only list of tracked tasks.
/// </summary>
public static IReadOnlyList<TaskInfo> Tasks => TrackedTasksInternal.ToArray();
/// <summary>
/// Clear the list of tracked tasks.
/// </summary>
public static void Clear() => clearRequested = true;
/// <summary>
/// Update the tracked data.
/// </summary>
public static void UpdateData()
{
if (clearRequested)
{
this.ApplyPatch();
var framework = Service<Framework>.Get();
framework.Update += this.FrameworkOnUpdate;
TrackedTasksInternal.Clear();
clearRequested = false;
}
/// <summary>
/// Gets a read-only list of tracked tasks.
/// </summary>
public static IReadOnlyList<TaskInfo> Tasks => TrackedTasksInternal.ToArray();
/// <summary>
/// Clear the list of tracked tasks.
/// </summary>
public static void Clear() => clearRequested = true;
/// <summary>
/// Update the tracked data.
/// </summary>
public static void UpdateData()
var i = 0;
var pruned = 0;
// Prune old tasks. Technically a memory "leak" that grows infinitely otherwise.
while (i < TrackedTasksInternal.Count)
{
if (clearRequested)
var taskInfo = TrackedTasksInternal[i];
if (taskInfo.IsCompleted && !taskInfo.IsBeingViewed && TrackedTasksInternal.Count > 1000)
{
TrackedTasksInternal.Clear();
clearRequested = false;
TrackedTasksInternal.RemoveAt(i);
pruned++;
continue;
}
var i = 0;
var pruned = 0;
// Prune old tasks. Technically a memory "leak" that grows infinitely otherwise.
while (i < TrackedTasksInternal.Count)
{
var taskInfo = TrackedTasksInternal[i];
if (taskInfo.IsCompleted && !taskInfo.IsBeingViewed && TrackedTasksInternal.Count > 1000)
{
TrackedTasksInternal.RemoveAt(i);
pruned++;
continue;
}
i++;
}
// if (pruned > 0)
// Log.Debug($"Pruned {pruned} tasks");
// Consume from a queue to prevent iteration errors
while (NewlyCreatedTasks.TryDequeue(out var newTask))
{
TrackedTasksInternal.Add(newTask);
}
// Update each task
for (i = 0; i < TrackedTasksInternal.Count; i++)
{
var taskInfo = TrackedTasksInternal[i];
if (taskInfo.Task == null)
continue;
taskInfo.IsCompleted = taskInfo.Task.IsCompleted;
taskInfo.IsFaulted = taskInfo.Task.IsFaulted;
taskInfo.IsCanceled = taskInfo.Task.IsCanceled;
taskInfo.IsCompletedSuccessfully = taskInfo.Task.IsCompletedSuccessfully;
taskInfo.Status = taskInfo.Task.Status;
if (taskInfo.IsCompleted || taskInfo.IsFaulted || taskInfo.IsCanceled ||
taskInfo.IsCompletedSuccessfully)
{
taskInfo.Exception = taskInfo.Task.Exception;
taskInfo.Task = null;
taskInfo.FinishTime = DateTime.Now;
}
}
i++;
}
/// <inheritdoc/>
public void Dispose()
{
this.scheduleAndStartHook?.Dispose();
// if (pruned > 0)
// Log.Debug($"Pruned {pruned} tasks");
var framework = Service<Framework>.Get();
framework.Update -= this.FrameworkOnUpdate;
// Consume from a queue to prevent iteration errors
while (NewlyCreatedTasks.TryDequeue(out var newTask))
{
TrackedTasksInternal.Add(newTask);
}
private static bool AddToActiveTasksHook(Func<Task, bool> orig, Task self)
// Update each task
for (i = 0; i < TrackedTasksInternal.Count; i++)
{
orig(self);
var taskInfo = TrackedTasksInternal[i];
if (taskInfo.Task == null)
continue;
var trace = new StackTrace();
NewlyCreatedTasks.Enqueue(new TaskInfo
taskInfo.IsCompleted = taskInfo.Task.IsCompleted;
taskInfo.IsFaulted = taskInfo.Task.IsFaulted;
taskInfo.IsCanceled = taskInfo.Task.IsCanceled;
taskInfo.IsCompletedSuccessfully = taskInfo.Task.IsCompletedSuccessfully;
taskInfo.Status = taskInfo.Task.Status;
if (taskInfo.IsCompleted || taskInfo.IsFaulted || taskInfo.IsCanceled ||
taskInfo.IsCompletedSuccessfully)
{
Task = self,
Id = self.Id,
StackTrace = trace,
});
taskInfo.Exception = taskInfo.Task.Exception;
return true;
}
private void FrameworkOnUpdate(Framework framework)
{
UpdateData();
}
private void ApplyPatch()
{
var targetType = typeof(Task);
var debugField = targetType.GetField("s_asyncDebuggingEnabled", BindingFlags.Static | BindingFlags.NonPublic);
debugField.SetValue(null, true);
Log.Information("s_asyncDebuggingEnabled: {0}", debugField.GetValue(null));
var targetMethod = targetType.GetMethod("AddToActiveTasks", BindingFlags.Static | BindingFlags.NonPublic);
var patchMethod = typeof(TaskTracker).GetMethod(nameof(AddToActiveTasksHook), BindingFlags.NonPublic | BindingFlags.Static);
if (targetMethod == null)
{
Log.Error("AddToActiveTasks TargetMethod null!");
return;
taskInfo.Task = null;
taskInfo.FinishTime = DateTime.Now;
}
if (patchMethod == null)
{
Log.Error("AddToActiveTasks PatchMethod null!");
return;
}
this.scheduleAndStartHook = new MonoMod.RuntimeDetour.Hook(targetMethod, patchMethod);
Log.Information("AddToActiveTasks Hooked!");
}
/// <summary>
/// Class representing a tracked task.
/// </summary>
internal class TaskInfo
{
/// <summary>
/// Gets or sets the tracked task.
/// </summary>
public Task? Task { get; set; }
/// <summary>
/// Gets or sets the ID of the task.
/// </summary>
public int Id { get; set; }
/// <summary>
/// Gets or sets the stack trace of where the task was started.
/// </summary>
public StackTrace? StackTrace { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not the task was completed.
/// </summary>
public bool IsCompleted { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not the task faulted.
/// </summary>
public bool IsFaulted { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not the task was canceled.
/// </summary>
public bool IsCanceled { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not the task was completed successfully.
/// </summary>
public bool IsCompletedSuccessfully { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this task is being viewed.
/// </summary>
public bool IsBeingViewed { get; set; }
/// <summary>
/// Gets or sets the status of the task.
/// </summary>
public TaskStatus Status { get; set; }
/// <summary>
/// Gets the start time of the task.
/// </summary>
public DateTime StartTime { get; } = DateTime.Now;
/// <summary>
/// Gets or sets the end time of the task.
/// </summary>
public DateTime FinishTime { get; set; }
/// <summary>
/// Gets or sets the exception that occurred within the task.
/// </summary>
public AggregateException? Exception { get; set; }
}
}
/// <inheritdoc/>
public void Dispose()
{
this.scheduleAndStartHook?.Dispose();
var framework = Service<Framework>.Get();
framework.Update -= this.FrameworkOnUpdate;
}
private static bool AddToActiveTasksHook(Func<Task, bool> orig, Task self)
{
orig(self);
var trace = new StackTrace();
NewlyCreatedTasks.Enqueue(new TaskInfo
{
Task = self,
Id = self.Id,
StackTrace = trace,
});
return true;
}
private void FrameworkOnUpdate(Framework framework)
{
UpdateData();
}
private void ApplyPatch()
{
var targetType = typeof(Task);
var debugField = targetType.GetField("s_asyncDebuggingEnabled", BindingFlags.Static | BindingFlags.NonPublic);
debugField.SetValue(null, true);
Log.Information("s_asyncDebuggingEnabled: {0}", debugField.GetValue(null));
var targetMethod = targetType.GetMethod("AddToActiveTasks", BindingFlags.Static | BindingFlags.NonPublic);
var patchMethod = typeof(TaskTracker).GetMethod(nameof(AddToActiveTasksHook), BindingFlags.NonPublic | BindingFlags.Static);
if (targetMethod == null)
{
Log.Error("AddToActiveTasks TargetMethod null!");
return;
}
if (patchMethod == null)
{
Log.Error("AddToActiveTasks PatchMethod null!");
return;
}
this.scheduleAndStartHook = new MonoMod.RuntimeDetour.Hook(targetMethod, patchMethod);
Log.Information("AddToActiveTasks Hooked!");
}
/// <summary>
/// Class representing a tracked task.
/// </summary>
internal class TaskInfo
{
/// <summary>
/// Gets or sets the tracked task.
/// </summary>
public Task? Task { get; set; }
/// <summary>
/// Gets or sets the ID of the task.
/// </summary>
public int Id { get; set; }
/// <summary>
/// Gets or sets the stack trace of where the task was started.
/// </summary>
public StackTrace? StackTrace { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not the task was completed.
/// </summary>
public bool IsCompleted { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not the task faulted.
/// </summary>
public bool IsFaulted { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not the task was canceled.
/// </summary>
public bool IsCanceled { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not the task was completed successfully.
/// </summary>
public bool IsCompletedSuccessfully { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this task is being viewed.
/// </summary>
public bool IsBeingViewed { get; set; }
/// <summary>
/// Gets or sets the status of the task.
/// </summary>
public TaskStatus Status { get; set; }
/// <summary>
/// Gets the start time of the task.
/// </summary>
public DateTime StartTime { get; } = DateTime.Now;
/// <summary>
/// Gets or sets the end time of the task.
/// </summary>
public DateTime FinishTime { get; set; }
/// <summary>
/// Gets or sets the exception that occurred within the task.
/// </summary>
public AggregateException? Exception { get; set; }
}
}

View file

@ -1,240 +1,239 @@
using System;
using System.Reflection;
namespace Dalamud.Logging
namespace Dalamud.Logging;
/// <summary>
/// Class offering various static methods to allow for logging in plugins.
/// </summary>
public static class PluginLog
{
#region "Log" prefixed Serilog style methods
/// <summary>
/// Class offering various static methods to allow for logging in plugins.
/// Log a templated message to the in-game debug log.
/// </summary>
public static class PluginLog
{
#region "Log" prefixed Serilog style methods
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Log(string messageTemplate, params object[] values)
=> Serilog.Log.Information($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Log(string messageTemplate, params object[] values)
=> Serilog.Log.Information($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Log(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Information(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Log(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Information(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogVerbose(string messageTemplate, params object[] values)
=> Serilog.Log.Verbose($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogVerbose(string messageTemplate, params object[] values)
=> Serilog.Log.Verbose($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogVerbose(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Verbose(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogVerbose(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Verbose(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogDebug(string messageTemplate, params object[] values)
=> Serilog.Log.Debug($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogDebug(string messageTemplate, params object[] values)
=> Serilog.Log.Debug($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogDebug(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Debug(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogDebug(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Debug(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogInformation(string messageTemplate, params object[] values)
=> Serilog.Log.Information($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogInformation(string messageTemplate, params object[] values)
=> Serilog.Log.Information($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogInformation(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Information(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogInformation(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Information(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogWarning(string messageTemplate, params object[] values)
=> Serilog.Log.Warning($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogWarning(string messageTemplate, params object[] values)
=> Serilog.Log.Warning($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogWarning(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Warning(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogWarning(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Warning(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogError(string messageTemplate, params object[] values)
=> Serilog.Log.Error($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogError(string messageTemplate, params object[] values)
=> Serilog.Log.Error($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogError(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Error(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogError(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Error(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogFatal(string messageTemplate, params object[] values)
=> Serilog.Log.Fatal($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogFatal(string messageTemplate, params object[] values)
=> Serilog.Log.Fatal($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogFatal(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Fatal(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void LogFatal(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Fatal(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
#endregion
#endregion
#region Serilog style methods
#region Serilog style methods
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Verbose(string messageTemplate, params object[] values)
=> Serilog.Log.Verbose($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Verbose(string messageTemplate, params object[] values)
=> Serilog.Log.Verbose($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Verbose(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Verbose(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated verbose message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Verbose(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Verbose(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Debug(string messageTemplate, params object[] values)
=> Serilog.Log.Debug($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Debug(string messageTemplate, params object[] values)
=> Serilog.Log.Debug($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Debug(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Debug(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated debug message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Debug(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Debug(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Information(string messageTemplate, params object[] values)
=> Serilog.Log.Information($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Information(string messageTemplate, params object[] values)
=> Serilog.Log.Information($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Information(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Information(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated information message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Information(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Information(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Warning(string messageTemplate, params object[] values)
=> Serilog.Log.Warning($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Warning(string messageTemplate, params object[] values)
=> Serilog.Log.Warning($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Warning(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Warning(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated warning message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Warning(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Warning(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Error(string messageTemplate, params object[] values)
=> Serilog.Log.Error($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Error(string messageTemplate, params object[] values)
=> Serilog.Log.Error($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Error(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Error(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated error message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Error(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Error(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Fatal(string messageTemplate, params object[] values)
=> Serilog.Log.Fatal($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Fatal(string messageTemplate, params object[] values)
=> Serilog.Log.Fatal($"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Fatal(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Fatal(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
/// <summary>
/// Log a templated fatal message to the in-game debug log.
/// </summary>
/// <param name="exception">The exception that caused the error.</param>
/// <param name="messageTemplate">The message template.</param>
/// <param name="values">Values to log.</param>
public static void Fatal(Exception exception, string messageTemplate, params object[] values)
=> Serilog.Log.Fatal(exception, $"[{Assembly.GetCallingAssembly().GetName().Name}] {messageTemplate}", values);
#endregion
}
#endregion
}