mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
R# cleanup
This commit is contained in:
@@ -41,6 +41,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
internal void LogChatMessage(bool echo, string message, ulong chatGroupID = 0, ulong chatID = 0, ulong steamID = 0, [CallerMemberName] string previousMethodName = null) {
|
||||
if (string.IsNullOrEmpty(message) || (((chatGroupID == 0) || (chatID == 0)) && (steamID == 0))) {
|
||||
LogNullError(nameof(message) + " || " + "((" + nameof(chatGroupID) + " || " + nameof(chatID) + ") && " + nameof(steamID) + ")");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,6 +70,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
internal async Task LogFatalException(Exception exception, [CallerMemberName] string previousMethodName = null) {
|
||||
if (exception == null) {
|
||||
LogNullError(nameof(exception));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,13 +87,13 @@ namespace ArchiSteamFarm.NLog {
|
||||
try {
|
||||
await RuntimeCompatibility.File.WriteAllTextAsync(SharedInfo.LogFile, message).ConfigureAwait(false);
|
||||
} catch {
|
||||
// Ignored, we can't do anything with this
|
||||
// Ignored, we can't do anything about this
|
||||
}
|
||||
|
||||
try {
|
||||
Console.Write(message);
|
||||
} catch {
|
||||
// Ignored, we can't do anything with this
|
||||
// Ignored, we can't do anything about this
|
||||
}
|
||||
|
||||
while (true) {
|
||||
@@ -100,17 +102,18 @@ namespace ArchiSteamFarm.NLog {
|
||||
try {
|
||||
await RuntimeCompatibility.File.AppendAllTextAsync(SharedInfo.LogFile, message).ConfigureAwait(false);
|
||||
} catch {
|
||||
// Ignored, we can't do anything with this
|
||||
// Ignored, we can't do anything about this
|
||||
}
|
||||
|
||||
try {
|
||||
Console.Write(message);
|
||||
} catch {
|
||||
// Ignored, we can't do anything with this
|
||||
// Ignored, we can't do anything about this
|
||||
}
|
||||
|
||||
if (exception.InnerException != null) {
|
||||
exception = exception.InnerException;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -121,6 +124,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
internal void LogGenericDebug(string message, [CallerMemberName] string previousMethodName = null) {
|
||||
if (string.IsNullOrEmpty(message)) {
|
||||
LogNullError(nameof(message));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -130,6 +134,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
internal void LogGenericDebuggingException(Exception exception, [CallerMemberName] string previousMethodName = null) {
|
||||
if (exception == null) {
|
||||
LogNullError(nameof(exception));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -143,6 +148,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
internal void LogGenericError(string message, [CallerMemberName] string previousMethodName = null) {
|
||||
if (string.IsNullOrEmpty(message)) {
|
||||
LogNullError(nameof(message));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -152,6 +158,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
internal void LogGenericException(Exception exception, [CallerMemberName] string previousMethodName = null) {
|
||||
if (exception == null) {
|
||||
LogNullError(nameof(exception));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,6 +168,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
internal void LogGenericInfo(string message, [CallerMemberName] string previousMethodName = null) {
|
||||
if (string.IsNullOrEmpty(message)) {
|
||||
LogNullError(nameof(message));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -170,6 +178,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
internal void LogGenericTrace(string message, [CallerMemberName] string previousMethodName = null) {
|
||||
if (string.IsNullOrEmpty(message)) {
|
||||
LogNullError(nameof(message));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -179,6 +188,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
internal void LogGenericWarning(string message, [CallerMemberName] string previousMethodName = null) {
|
||||
if (string.IsNullOrEmpty(message)) {
|
||||
LogNullError(nameof(message));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -188,6 +198,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
internal void LogGenericWarningException(Exception exception, [CallerMemberName] string previousMethodName = null) {
|
||||
if (exception == null) {
|
||||
LogNullError(nameof(exception));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,11 @@ namespace ArchiSteamFarm.NLog {
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public byte MaxCount {
|
||||
get => HistoryQueue.MaxCount;
|
||||
|
||||
set {
|
||||
if (value == 0) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(value));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,6 +63,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
protected override void Write(LogEventInfo logEvent) {
|
||||
if (logEvent == null) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(logEvent));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
}
|
||||
|
||||
bool reload = false;
|
||||
|
||||
foreach (LoggingRule rule in LogManager.Configuration.LoggingRules.Where(rule => rule.IsLoggingEnabledForLevel(LogLevel.Debug) && !rule.IsLoggingEnabledForLevel(LogLevel.Trace))) {
|
||||
rule.EnableLoggingForLevel(LogLevel.Trace);
|
||||
reload = true;
|
||||
@@ -57,6 +58,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
IsUsingCustomConfiguration = true;
|
||||
InitConsoleLoggers();
|
||||
LogManager.ConfigurationChanged += OnConfigurationChanged;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -89,7 +91,6 @@ namespace ArchiSteamFarm.NLog {
|
||||
HistoryTarget historyTarget = LogManager.Configuration.AllTargets.OfType<HistoryTarget>().FirstOrDefault();
|
||||
|
||||
if ((historyTarget == null) && !IsUsingCustomConfiguration) {
|
||||
// TODO: We could use some nice HTML layout for this
|
||||
historyTarget = new HistoryTarget("History") {
|
||||
Layout = GeneralLayout,
|
||||
MaxCount = 20
|
||||
@@ -154,6 +155,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
private static void OnConfigurationChanged(object sender, LoggingConfigurationChangedEventArgs e) {
|
||||
if ((sender == null) || (e == null)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
protected override async void Write(LogEventInfo logEvent) {
|
||||
if (logEvent == null) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(logEvent));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -89,6 +90,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
private async Task SendGroupMessage(string message, Bot bot = null) {
|
||||
if (string.IsNullOrEmpty(message)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(message));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,6 +108,7 @@ namespace ArchiSteamFarm.NLog {
|
||||
private async Task SendPrivateMessage(string message, Bot bot = null) {
|
||||
if (string.IsNullOrEmpty(message)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(message));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user