Migrate files to Dalamud.Logging namespace Remove Log.LogX methods.

This commit is contained in:
Raymond 2021-08-09 10:03:13 -04:00
parent 6c56260f45
commit 8fd119dde8
16 changed files with 128 additions and 252 deletions

View file

@ -6,7 +6,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dalamud.Configuration.Internal; using Dalamud.Configuration.Internal;
using Dalamud.Interface.Internal; using Dalamud.Logging.Internal;
using Newtonsoft.Json; using Newtonsoft.Json;
using Serilog; using Serilog;
using Serilog.Core; using Serilog.Core;

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Dalamud.Logging.Internal;
using Dalamud.Memory; using Dalamud.Memory;
using Microsoft.Win32; using Microsoft.Win32;

View file

@ -6,7 +6,8 @@ using System.Runtime.InteropServices;
using Dalamud.Interface.Internal.Windows; using Dalamud.Interface.Internal.Windows;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Plugin; using Dalamud.Logging;
using Dalamud.Logging.Internal;
using Dalamud.Plugin.Internal; using Dalamud.Plugin.Internal;
using ImGuiNET; using ImGuiNET;
using Serilog.Events; using Serilog.Events;

View file

@ -11,6 +11,7 @@ using Dalamud.Game.ClientState;
using Dalamud.Game.Internal.DXGI; using Dalamud.Game.Internal.DXGI;
using Dalamud.Hooking; using Dalamud.Hooking;
using Dalamud.Hooking.Internal; using Dalamud.Hooking.Internal;
using Dalamud.Logging.Internal;
using ImGuiNET; using ImGuiNET;
using ImGuiScene; using ImGuiScene;
using Serilog; using Serilog;

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Dalamud.Plugin; using Dalamud.Logging;
namespace Dalamud.Interface.Internal.Scratchpad namespace Dalamud.Interface.Internal.Scratchpad
{ {

View file

@ -6,10 +6,9 @@ using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Dalamud.Configuration.Internal;
using Dalamud.Game.Command;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Logging.Internal;
using ImGuiNET; using ImGuiNET;
using Serilog; using Serilog;
using Serilog.Events; using Serilog.Events;
@ -307,7 +306,7 @@ namespace Dalamud.Interface.Internal.Windows
try try
{ {
this.historyPos = -1; this.historyPos = -1;
for (int i = this.history.Count - 1; i >= 0; i--) for (var i = this.history.Count - 1; i >= 0; i--)
{ {
if (this.history[i] == this.commandText) if (this.history[i] == this.commandText)
{ {

View file

@ -13,6 +13,7 @@ using CheapLoc;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Components; using Dalamud.Interface.Components;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Logging.Internal;
using Dalamud.Plugin; using Dalamud.Plugin;
using Dalamud.Plugin.Internal; using Dalamud.Plugin.Internal;
using Dalamud.Plugin.Internal.Exceptions; using Dalamud.Plugin.Internal.Exceptions;

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using ImGuiNET; using ImGuiNET;
using Serilog;
namespace Dalamud.Interface.Windowing namespace Dalamud.Interface.Windowing
{ {

View file

@ -1,6 +1,6 @@
using System; using System;
namespace Dalamud namespace Dalamud.Logging.Internal
{ {
/// <summary> /// <summary>
/// Class offering various methods to allow for logging in Dalamud modules. /// Class offering various methods to allow for logging in Dalamud modules.

View file

@ -3,7 +3,7 @@ using System;
using Serilog.Core; using Serilog.Core;
using Serilog.Events; using Serilog.Events;
namespace Dalamud.Interface.Internal namespace Dalamud.Logging.Internal
{ {
/// <summary> /// <summary>
/// Serilog event sink. /// Serilog event sink.

View file

@ -0,0 +1,113 @@
using System;
using System.Reflection;
namespace Dalamud.Logging
{
/// <summary>
/// Class offering various static methods to allow for logging in plugins.
/// </summary>
public static class PluginLog
{
/// <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 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 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 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 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 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);
}
}

View file

@ -1,10 +1,10 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dalamud.Configuration.Internal; using Dalamud.Configuration.Internal;
using Dalamud.Logging.Internal;
using Dalamud.Plugin.Internal.Types; using Dalamud.Plugin.Internal.Types;
namespace Dalamud.Plugin.Internal namespace Dalamud.Plugin.Internal

View file

@ -3,8 +3,8 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Dalamud.Configuration.Internal;
using Dalamud.Game; using Dalamud.Game;
using Dalamud.Logging.Internal;
using Dalamud.Plugin.Internal.Exceptions; using Dalamud.Plugin.Internal.Exceptions;
using Dalamud.Plugin.Internal.Types; using Dalamud.Plugin.Internal.Types;
using McMaster.NETCore.Plugins; using McMaster.NETCore.Plugins;

View file

@ -14,6 +14,7 @@ using System.Threading.Tasks;
using CheapLoc; using CheapLoc;
using Dalamud.Configuration; using Dalamud.Configuration;
using Dalamud.Game.Text; using Dalamud.Game.Text;
using Dalamud.Logging.Internal;
using Dalamud.Plugin.Internal.Exceptions; using Dalamud.Plugin.Internal.Exceptions;
using Dalamud.Plugin.Internal.Types; using Dalamud.Plugin.Internal.Types;
using HarmonyLib; using HarmonyLib;

View file

@ -1,9 +1,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dalamud.Logging.Internal;
using Dalamud.Plugin.Internal.Types; using Dalamud.Plugin.Internal.Types;
using Newtonsoft.Json; using Newtonsoft.Json;

View file

@ -1,240 +0,0 @@
using System;
using System.Reflection;
namespace Dalamud.Plugin
{
/// <summary>
/// Class offering various static methods to allow for logging in plugins.
/// </summary>
public static class PluginLog
{
#region "Log" prefixed Serilog style methods
/// <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 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 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 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 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 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 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);
#endregion
#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="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="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="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="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="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="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
}
}