add logging of invites (#2005)

* add logging of invites

* required changes

* revert not needed changes

* remove not needed convertation
This commit is contained in:
Ryzhehvost
2020-10-07 22:22:39 +03:00
committed by GitHub
parent e1e4f9a8b4
commit 2a71e2cb0b
2 changed files with 17 additions and 0 deletions

View File

@@ -2161,6 +2161,8 @@ namespace ArchiSteamFarm {
}
foreach (SteamFriends.FriendsListCallback.Friend friend in callback.FriendList.Where(friend => friend.Relationship == EFriendRelationship.RequestRecipient)) {
ArchiLogger.LogInvite(friend.SteamID);
switch (friend.SteamID.AccountType) {
case EAccountType.Clan when IsMasterClanID(friend.SteamID):
ArchiHandler.AcknowledgeClanInvite(friend.SteamID, true);

View File

@@ -26,6 +26,7 @@ using System.Threading.Tasks;
using ArchiSteamFarm.Localization;
using JetBrains.Annotations;
using NLog;
using SteamKit2;
namespace ArchiSteamFarm.NLog {
public sealed class ArchiLogger {
@@ -151,6 +152,20 @@ namespace ArchiSteamFarm.NLog {
Logger.Log(logEventInfo);
}
internal void LogInvite(SteamID steamID, [CallerMemberName] string? previousMethodName = null) {
if ((steamID.AccountType == EAccountType.Invalid) || (steamID == 0)) {
throw new ArgumentNullException(nameof(steamID) + " || " + nameof(steamID.AccountType));
}
string loggedMessage = previousMethodName + "() " + steamID.AccountType + " " + steamID.ConvertToUInt64().ToString();
LogEventInfo logEventInfo = new LogEventInfo(LogLevel.Trace, Logger.Name, loggedMessage);
logEventInfo.Properties["SteamID"] = steamID.ConvertToUInt64();
logEventInfo.Properties["AccountType"] = steamID.AccountType;
Logger.Log(logEventInfo);
}
internal async Task LogFatalException(Exception exception, [CallerMemberName] string? previousMethodName = null) {
if (exception == null) {
throw new ArgumentNullException(nameof(exception));