private void AppendLogToFile(SessionLogMessage logmsg) { try { string securePath = ConfigurationManager.AppSettings["SecurePath"]; string logSessionToFileSetting = ConfigurationManager.AppSettings["LogSessionToFile"]; if (!string.IsNullOrEmpty(securePath) && !string.IsNullOrEmpty(logSessionToFileSetting)) { if (bool.TryParse(logSessionToFileSetting, out bool logSessionToFile)) { if (logSessionToFile) { lock (_lockingTarget) { var logDir = Path.Combine(securePath, "logs", Provider.Log.Name); if (!Directory.Exists(logDir)) { Directory.CreateDirectory(logDir); } var logFile = Path.Combine(logDir, "Session.log"); File.AppendAllText(logFile, logmsg.Message + Environment.NewLine); } } } } } catch { } //silently fail, we don't want an error here to f**k everything up }
private void LogLinkedFileDiffMergingSessionInfo(LinkedFileDiffMergingSessionInfo sessionInfo) { // don't report telemetry if (!_logSessionInfo) { return; } var sessionId = SessionLogMessage.GetNextId(); Logger.Log(FunctionId.Workspace_Solution_LinkedFileDiffMergingSession, SessionLogMessage.Create(sessionId, sessionInfo)); foreach (var groupInfo in sessionInfo.LinkedFileGroups) { Logger.Log(FunctionId.Workspace_Solution_LinkedFileDiffMergingSession_LinkedFileGroup, SessionLogMessage.Create(sessionId, groupInfo)); } }
public void AppendLog(string msg) { List <SessionLogMessage> log; int clientId = 0; string username = "******"; var currentUser = CurrentUser(); if (currentUser != null) { clientId = currentUser.ClientID; username = currentUser.UserName; } DateTime now = DateTime.Now; SessionLogMessage logmsg; if (Context.Session["SessionLog"] == null) { logmsg = new SessionLogMessage { ClientID = clientId, UserName = username, LogDateTime = now, Text = "Started SessionLog" }; log = new List <SessionLogMessage> { logmsg }; AppendLogToFile(logmsg); Context.Session["SessionLog"] = log; } else { log = (List <SessionLogMessage>)Context.Session["SessionLog"]; } if (!string.IsNullOrEmpty(msg)) { logmsg = new SessionLogMessage { ClientID = clientId, UserName = username, LogDateTime = now, Text = msg }; log.Add(logmsg); AppendLogToFile(logmsg); } }
internal static void LogSession(Workspace workspace, LinkedFileDiffMergingSessionInfo sessionInfo) { if (sessionInfo.LinkedFileGroups.Count > 1) { LogNewSessionWithLinkedFiles(); LogNumberOfLinkedFileGroupsProcessed(sessionInfo.LinkedFileGroups.Count); foreach (var groupInfo in sessionInfo.LinkedFileGroups) { LogNumberOfIdenticalDiffs(groupInfo.IdenticalDiffs); LogNumberOfIsolatedDiffs(groupInfo.IsolatedDiffs); LogNumberOfOverlappingDistinctDiffs(groupInfo.OverlappingDistinctDiffs); LogNumberOfOverlappingDistinctDiffsWithSameSpan(groupInfo.OverlappingDistinctDiffsWithSameSpan); LogNumberOfOverlappingDistinctDiffsWithSameSpanAndSubstringRelation(groupInfo.OverlappingDistinctDiffsWithSameSpanAndSubstringRelation); LogNumberOfInsertedMergeConflictComments(groupInfo.InsertedMergeConflictComments); LogNumberOfInsertedMergeConflictCommentsAtAdjustedLocation(groupInfo.InsertedMergeConflictCommentsAtAdjustedLocation); if (groupInfo.InsertedMergeConflictComments > 0 || groupInfo.InsertedMergeConflictCommentsAtAdjustedLocation > 0) { Logger.Log(FunctionId.Workspace_Solution_LinkedFileDiffMergingSession_LinkedFileGroup, SessionLogMessage.Create(groupInfo)); } } } }