/// <summary> /// Get a count of log items matching the filter criteria /// </summary> /// <param name="userKey">User Key of the user who initiates the call.</param> /// <param name="listId">ID of the list.</param> /// <param name="logType">Filter using the log action. Possible values: "subscribe", "in_queue", "opened", "clickthru", "forward", "unsubscribe", "view", "spam", "skipped"</param> /// <param name="uniques">Return unique log items per member</param> /// <param name="totals">Return all the log items</param> /// <param name="start">Filter using a start date</param> /// <param name="end">Filter using an end date</param> /// <param name="clientId">Client ID of the client in which the list is located.</param> /// <param name="cancellationToken">The cancellation token</param> /// <returns>The number of log items matching the filtering criteria</returns> public Task <long> GetLogsCountAsync(string userKey, long listId, LogType?logType = null, bool uniques = false, bool totals = false, DateTime?start = null, DateTime?end = null, long?clientId = null, CancellationToken cancellationToken = default(CancellationToken)) { var parameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("user_key", userKey), new KeyValuePair <string, object>("list_id", listId), new KeyValuePair <string, object>("totals", totals ? "true" : "false"), new KeyValuePair <string, object>("uniques", uniques ? "true" : "false"), new KeyValuePair <string, object>("count", "true") }; if (logType.HasValue) { parameters.Add(new KeyValuePair <string, object>("action", logType.Value.GetEnumMemberValue())); } if (start.HasValue) { parameters.Add(new KeyValuePair <string, object>("start_time", start.Value.ToCakeMailString())); } if (end.HasValue) { parameters.Add(new KeyValuePair <string, object>("end_time", end.Value.ToCakeMailString())); } if (clientId.HasValue) { parameters.Add(new KeyValuePair <string, object>("client_id", clientId.Value)); } return(_client .PostAsync("List/GetLog") .WithFormUrlEncodedBody(parameters) .WithCancellationToken(cancellationToken) .AsCakeMailObject <long>("count")); }
public static void LoggerCallback(LogType?logType, string[] lines) { foreach (var line in lines) { LoggerCallback(logType, line); } }
public static bool IsPassedThrough(this LogType baseType, LogType?otherType) { if (otherType == null) { return(false); } var other = otherType.Value; switch (baseType) { case LogType.Exception: return(true); case LogType.Assert: return(other != LogType.Exception); case LogType.Error: return(other != LogType.Exception && other != LogType.Assert); case LogType.Warning: return(other == LogType.Log || other == LogType.Warning); case LogType.Log: return(other == LogType.Log); } return(true); }
public static void LoggerCallback(LogType?logTypeArg, string line) { var logType = logTypeArg ?? LogHelper.DetermineLogTypeForOutputLine(line); if (ShouldJustPrintCommands) { switch (logType) { case LogType.Command: LogHelper.SafeConsoleWriteLine(LogHelper.AdjustCommandLineForDisplay(line)); break; case LogType.Warning: LogHelper.SafeConsoleWriteLine($"REM Warning. {line}"); break; case LogType.Error: LogHelper.SafeConsoleWriteLine($"REM Error. {line}"); break; } return; } if (!LogHelper.ShowForVerboseLevel(logType)) { return; } LogHelper.TryToExtractSonarProjectUrl(line); LogHelper.DetermineColorAndPrefix(logType, out var foregroundColor, out var prefix); var formattedPrefix = (prefix != null) ? $"{prefix,-7} " : ""; LogHelper.SafeConsoleWriteLine(line, foregroundColor, formattedPrefix); }
public IPagedList <Log> GetAllLogs(DateTime?fromUtc = default(DateTime?), DateTime?toUtc = default(DateTime?), string message = "", LogType?logType = default(LogType?), int pageIndex = 0, int pageSize = int.MaxValue) { var query = _logRepository.Table(); if (fromUtc.HasValue) { query = query.Where(l => fromUtc.Value <= l.CreatedOnUtc); } if (toUtc.HasValue) { query = query.Where(l => toUtc.Value >= l.CreatedOnUtc); } if (logType.HasValue) { var logTypeId = (int)logType.Value; query = query.Where(l => logTypeId == l.LogTypeId); } if (!String.IsNullOrEmpty(message)) { query = query.Where(l => l.ShortMessage.Contains(message) || l.FullMessage.Contains(message)); } query = query.OrderByDescending(l => l.CreatedOnUtc); var log = new PagedList <Log>(query, pageIndex, pageSize); return(log); }
internal Event(string context, Metadata metadata, App app, Device device, User user, Exception[] exceptions, HandledState handledState, Breadcrumb[] breadcrumbs, Session session, LogType?logType = null) { OriginalSeverity = handledState; Metadata = metadata; HandledState = handledState; LogType = logType; this.AddToPayload("context", context); this.AddToPayload("payloadVersion", 4); this.AddToPayload("exceptions", exceptions); this.AddToPayload("app", app); this.AddToPayload("device", device); this.AddToPayload("metaData", Metadata); this.AddToPayload("breadcrumbs", breadcrumbs); this.AddToPayload("session", session); if (session != null) { if (handledState.Handled) { session.Events.IncrementHandledCount(); } else { session.Events.IncrementUnhandledCount(); } } this.AddToPayload("user", user); }
public void Call_Log_with_message(string message, LogType?logType) { Mock <Logger> mock; Logger logger; if (logType.HasValue) { mock = new Mock <Logger>(logType.Value); logger = mock.Object; switch (logType) { case LogType.Console: Assert.IsAssignableFrom(typeof(ConsoleLogger), logger.MessageLogger); break; case LogType.Queue: Assert.IsAssignableFrom(typeof(QueueLogger), logger.MessageLogger); break; } } else { mock = new Mock <Logger>(); logger = mock.Object; Assert.IsAssignableFrom(typeof(ConsoleLogger), logger.MessageLogger); } logger.Log(message); }
/// <summary> /// Export logs of a certain type /// </summary> /// <param name="logType">The type of log that needs to be exported</param> private void ExportLogs(LogType?logType) { if (Utils.ExportLogs(logType, _logController)) { MessageBox.Show((string)Application.Current.FindResource("ExportedAllData"), "MemPlus", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void OnLogReceive(ApplicationLogHandler.LogInfo logInfo) { var srDebug = SRDebug.Instance; if (srDebug == null) { return; } var changeColor = true; var ignoreWarnings = new string[] { "SpriteAtlasManager.atlasRequested wasn't listened to while", }; foreach (var ignore in ignoreWarnings) { if (logInfo.Condition.StartsWith(ignore)) { return; } } if (currentLogType.HasValue) { var priority = LogPriority.IndexOf(x => x == logInfo.Type); var current = LogPriority.IndexOf(x => x == currentLogType.Value); changeColor = current < priority; } if (changeColor) { var color = defaultColor; switch (logInfo.Type) { case LogType.Warning: color = warningColor; break; case LogType.Error: color = errorColor; break; case LogType.Exception: color = exceptionColor; break; } if (!srDebug.IsDebugPanelVisible) { background.color = lastShowLogTime < Time.realtimeSinceStartup ? color : defaultColor; } currentLogType = logInfo.Type; } }
private void LogAction(string text, TimeSpan?responseTime = null, LogType?action = null) { const int cResponseTimeWidth = 8; var responseTimeString = new string(' ', cResponseTimeWidth); if (responseTime != null) { responseTimeString = responseTime.Value.TotalMilliseconds.ToString("0") + " ms"; responseTimeString = responseTimeString.PadLeft(cResponseTimeWidth); } LastMessageSend = DateTime.Now; string message = string.Format("[{0}] {1} {2} {3}", LastMessageSend.ToString("HH:mm:ss"), QboxSerial, responseTimeString, text); _log.AppendLine(message); Logger.Info(message); if (action.HasValue) { if (action == LogType.Success) { LastMessageFailed = false; } else if (action == LogType.Failed) { LastMessageFailed = true; } } if (responseTime != null) { ResponseTime = responseTime.Value; if (ResponseTime < MinResponseTime || MinResponseTime == TimeSpan.Zero) { MinResponseTime = ResponseTime; } if (ResponseTime > MaxResponseTime) { MaxResponseTime = ResponseTime; } } if (action == LogType.Failed) { FailedCount++; } // prevents race condition var onlogEvent = OnLog; if (onlogEvent != null) { onlogEvent(this, EventArgs.Empty); } }
private void OnLogReceive(ApplicationLogHandler.LogInfo logInfo) { var changeColor = true; //----- TODO: Unity2018.2以降で無駄な警告が出るので、修正されるまで除外. ----- var ignoreUnity2018_2Warnings = new string[] { "Your multi-scene setup may be improved by tending to the following issues", "Your current multi-scene setup has inconsistent Lighting settings", }; foreach (var ignore in ignoreUnity2018_2Warnings) { if (logInfo.Condition.StartsWith(ignore)) { return; } } //----------------------------------------------------------------------------------- if (currentLogType.HasValue) { var priority = LogPriority.IndexOf(x => x == logInfo.Type); var current = LogPriority.IndexOf(x => x == currentLogType.Value); changeColor = current < priority; } if (changeColor) { var color = defaultColor; switch (logInfo.Type) { case LogType.Warning: color = warningColor; break; case LogType.Error: color = errorColor; break; case LogType.Exception: color = exceptionColor; break; } if (!SRDebug.Instance.IsDebugPanelVisible) { background.color = lastShowLogTime < Time.realtimeSinceStartup ? color : defaultColor; } currentLogType = logInfo.Type; } }
private void OnClick() { if (!SRDebug.Instance.IsDebugPanelVisible) { SRDebug.Instance.ShowDebugPanel(); background.color = defaultColor; currentLogType = null; lastShowLogTime = Time.realtimeSinceStartup; } }
internal static Dictionary <string, string> WithLogType(LogType?logType) { var data = ForUnityException(true); if (logType.HasValue) { data["unityLogType"] = logType.Value.ToString("G"); } return(data); }
public List <Log> GetLogs(LogLevel?logLevel = null, LogType?logType = null, string machineId = null, string username = null, string keyword = null, int page = 0) { return(_logRepository.GetList() .Where(l => logLevel == null || l.LogLevel == logLevel) .Where(l => logType == null || l.LogType == logType) .Where(l => username == null || l.UserId == username) .Where(l => keyword == null || OtherFieldsContainKeyword(l, keyword)).Skip(page * PageSize) .Take(PageSize).OrderByDescending(x => x.TimeStamp).ToList()); }
/// <summary> /// Retrieve the list of available Log objects of a specific LogType /// </summary> /// <param name="logType">The LogType of the Log objects that should be returned</param> /// <returns>A list of Log objects that are of the specified LogType</returns> internal List <Log> GetLogs(LogType?logType) { if (logType == null) { return(GetLogs()); } List <Log> logList = _logList.Where(l => l.LogType == logType).ToList(); return(logList); }
/// <summary> /// Export logs to the disk /// </summary> /// <param name="logType">The LogType that should be exported (can be null to export all logs)</param> /// <param name="logController">The LogController object that can be used to export logs</param> /// <returns>True if the operation completed successfully, otherwise false</returns> internal static bool ExportLogs(LogType?logType, LogController logController) { if (logType != null) { if (logController.GetLogs(logType).Count == 0) { return(false); } } SaveFileDialog sfd = new SaveFileDialog { Filter = "Text file (*.txt)|*.txt|HTML file (*.html)|*.html|CSV file (*.csv)|*.csv|Excel file (*.csv)|*.csv" }; if (sfd.ShowDialog() != true) { return(false); } ExportTypes.ExportType type; switch (sfd.FilterIndex) { default: type = ExportTypes.ExportType.Text; break; case 2: type = ExportTypes.ExportType.Html; break; case 3: type = ExportTypes.ExportType.Csv; break; case 4: type = ExportTypes.ExportType.Excel; break; } try { logController.Export(sfd.FileName, logType, type); return(true); } catch (Exception ex) { logController.AddLog(new ApplicationLog(ex.Message)); MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error); } return(false); }
/// <summary> /// Export logs to the disk /// </summary> /// <param name="path">The path where logs should be stored</param> /// <param name="logType">The type of logs that should be saved. Can be null if all logs should be saved</param> /// <param name="exportType">The type of export that should be performed</param> internal void Export(string path, LogType?logType, ExportType exportType) { if (_logList.Count == 0) { return; } List <Log> exportList; if (logType != null) { exportList = new List <Log>(); foreach (Log l in _logList) { if (l.LogType == logType) { exportList.Add(l); } } } else { exportList = _logList; } if (exportList == null || exportList.Count == 0) { throw new ArgumentNullException(); } // ReSharper disable once SwitchStatementMissingSomeCases switch (exportType) { case ExportType.Html: LogExporter.ExportHtml(path, exportList); break; default: LogExporter.ExportTxt(path, exportList); break; case ExportType.Csv: LogExporter.ExportCsv(path, exportList); break; case ExportType.Excel: LogExporter.ExportExcel(path, exportList); break; } }
public async Task Get_User_Logs_By_Date_Window_And_Severity_And_Type_Async_Test() { // Arrange DateTime?start = newlog.DateCreated, end = newlog.DateCreated; LogSeverity?severity = newlog.Severity; LogType? type = newlog.Type; // Act var existedLogs = await logService.GetUserLogsAsync(userId, start, end, severity, type); // Assert Assert.NotNull(existedLogs); Assert.NotEmpty(existedLogs); }
/// <summary> /// Retrieve the log items for a given mailing /// </summary> /// <param name="userKey">User Key of the user who initiates the call.</param> /// <param name="mailingId">ID of the mailing.</param> /// <param name="logType">Filter using the log action. Possible values: "in_queue", "opened", "clickthru", "forward", "unsubscribe", "view", "spam", "skipped"</param> /// <param name="listMemberId">Filter using the ID of the member.</param> /// <param name="uniques">Return unique log item per member.</param> /// <param name="totals">Return all the log items.</param> /// <param name="start">Filter using a start date</param> /// <param name="end">Filter using an end date</param> /// <param name="limit">Limit the number of resulting log items.</param> /// <param name="offset">Offset the beginning of resulting log items.</param> /// <param name="clientId">Client ID of the client in which the mailing is located.</param> /// <param name="cancellationToken">The cancellation token</param> /// <returns>An enumeration of <see cref="LogItem">log items</see> matching the filter criteria</returns> /// <remarks> /// CakeMail throws an exception if you attempt to retrieve the logs for a mailing that hasn't been sent. /// The current error message is cryptic: Table 'api_cake_logs.mailing_xxxxxxx_big' doesn't exist. /// I was assured in May 2015 that they will improve this message to make it more informative. /// </remarks> public Task <LogItem[]> GetLogsAsync(string userKey, long mailingId, LogType?logType = null, long?listMemberId = null, bool uniques = false, bool totals = false, DateTime?start = null, DateTime?end = null, int?limit = 0, int?offset = 0, long?clientId = null, CancellationToken cancellationToken = default(CancellationToken)) { var parameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("user_key", userKey), new KeyValuePair <string, object>("mailing_id", mailingId), new KeyValuePair <string, object>("totals", totals ? "true" : "false"), new KeyValuePair <string, object>("uniques", uniques ? "true" : "false"), new KeyValuePair <string, object>("count", "false") }; if (logType.HasValue) { parameters.Add(new KeyValuePair <string, object>("action", logType.Value.GetEnumMemberValue())); } if (start.HasValue) { parameters.Add(new KeyValuePair <string, object>("start_time", start.Value.ToCakeMailString())); } if (end.HasValue) { parameters.Add(new KeyValuePair <string, object>("end_time", end.Value.ToCakeMailString())); } if (listMemberId.HasValue) { parameters.Add(new KeyValuePair <string, object>("record_id", listMemberId.Value)); } if (limit > 0) { parameters.Add(new KeyValuePair <string, object>("limit", limit)); } if (offset > 0) { parameters.Add(new KeyValuePair <string, object>("offset", offset)); } if (clientId.HasValue) { parameters.Add(new KeyValuePair <string, object>("client_id", clientId.Value)); } return(_client .PostAsync("Mailing/GetLog") .WithFormUrlEncodedBody(parameters) .WithCancellationToken(cancellationToken) .AsCakeMailObject <LogItem[]>("logs")); }
public override void NavigatedTo(object parameter = null) { try { base.NavigatedTo(parameter); Logs = null; _selectedLogType = null; _selectedDay = DateTime.Now; LoadLogs(); } catch (Exception e) { _logsService?.WriteError(e); } }
/// <summary> /// enable or disable a log item filer for the specified properties. null values act as wildcards making accepting any value /// </summary> /// <param name="isEnabled">enabled (true), disabled (false)</param> /// <param name="caller">caller object</param> /// <param name="callerTypeName">caller type name</param> /// <param name="callerMemberName">caller member name</param> /// <param name="logType">log entry type</param> /// <param name="logCategory">log entry category</param> /// <returns>the log filter</returns> public ILogFilter SetIsEnabledFilter( bool isEnabled, object caller = null, string callerTypeName = null, string callerMemberName = null, LogType?logType = null, LogCategory?logCategory = null ) { FilterValues.AddOrSetValue( isEnabled, caller, callerTypeName, callerMemberName, logType, logCategory); return(this); }
public ILoggingEventPropertiesBuilder WithException(Exception exception) { LogEventType = GetLogType(exception); _props["LogType"] = LogEventType.ToString(); if (exception != null) { _props["Exception"] = new LoggableException(exception); var httpException = exception as HttpException; if (httpException != null) { _props["ExceptionMessage"] = httpException.Message; _props["ErrorCode"] = httpException.ErrorCode; } } return(this); }
public void Initialize() { if (!initialized && IsEnable()) { SRDebug.Init(); var srDebug = SRDebug.Instance; UnityUtility.SetActive(blockCollider, srDebug.IsDebugPanelVisible); VisibilityChangedDelegate onPanelVisibilityChanged = visible => { if (visible) { background.color = defaultColor; currentLogType = null; lastShowLogTime = Time.realtimeSinceStartup; } UnityUtility.SetActive(blockCollider, visible); }; srDebug.PanelVisibilityChanged += onPanelVisibilityChanged; button.OnClickAsObservable() .Subscribe(_ => srDebug.ShowDebugPanel()) .AddTo(this); ApplicationLogHandler.Instance.OnLogReceiveAsObservable() .Subscribe(x => OnLogReceive(x)) .AddTo(this); #if ENABLE_SRDEBUGGER SRTrackLogService.Initialize(); #endif UnityUtility.SetActive(blockCollider, false); background.color = defaultColor; initialized = true; } }
//----- method ----- public void Initialize() { if (!initialized && IsEnable) { SRDebug.Init(); var srDebug = SRDebug.Instance; var logTracker = UnityLogTracker.Instance; var applicationLogHandler = ApplicationLogHandler.Instance; SetTouchBlock(touchBlock); VisibilityChangedDelegate onPanelVisibilityChanged = visible => { if (visible) { background.color = defaultColor; currentLogType = null; lastShowLogTime = Time.realtimeSinceStartup; } UnityUtility.SetActive(touchBlock, visible); }; srDebug.PanelVisibilityChanged += onPanelVisibilityChanged; button.OnClickAsObservable() .Subscribe(_ => srDebug.ShowDebugPanel()) .AddTo(this); applicationLogHandler.OnReceivedThreadedAllAsObservable() .ObserveOnMainThread() .Subscribe(x => OnLogReceive(x)) .AddTo(this); logTracker.Initialize(); background.color = defaultColor; initialized = true; } }
/// <inheritdoc /> public virtual void ChangeLog(Guid id, string?message, LogType?type) { var log = new LogDto { Id = id }; Logs.Attach(log); if (message != null) { log.Message = message; } if (type != null) { log.Type = type.GetValueOrDefault(); } SaveChanges(); }
/// <summary> /// Clear all Log objects that have a specific LogType /// </summary> /// <param name="logType">The LogType that Log objects need to contain in order to be removed</param> internal void ClearLogs(LogType?logType) { if (logType == null) { ClearLogs(); return; } List <Log> deleted = new List <Log>(); for (int i = _logList.Count - 1; i >= 0; i--) { if (_logList[i].LogType != logType) { continue; } deleted.Add(_logList[i]); _logList.RemoveAt(i); } LogTypeClearedEvent?.Invoke(deleted); }
/// <inheritdoc /> /// <summary> /// Initialize a new LogWindow object /// </summary> /// <param name="logController">The LogController object that can be used to add and view logs</param> /// <param name="logType">The LogType that is currently being monitored. Can be null if all logs should be monitored</param> internal LogWindow(LogController logController, LogType?logType) { _logController = logController; _logController.AddLog(new ApplicationLog("Initializing LogWindow")); _logType = logType; InitializeComponent(); ChangeVisualStyle(); LoadProperties(); FillLogView(); _logController.LogAddedEvent += LogAddedEvent; _logController.LogsClearedEvent += LogsClearedEvent; _logController.LogDeletedEvent += LogDeletedEvent; _logController.LogTypeClearedEvent += LogTypeClearedEvent; _autoScroll = true; _logController.AddLog(new ApplicationLog("Done initializing LogWindow")); }
/// <summary> /// 记录组件日志 /// </summary> /// <param name="logInfo">日志内容</param> public static void AddLog(string Msg, LogType?logtype = null) { try { logtype = logtype ?? LogType.INFO; CheckDir(); string sFileName = null;; if (logtype == LogType.INFO) { sFileName = LogDire + LogName_Info + "M" + DateTime.Now.Month.ToString() + "D" + DateTime.Now.Day.ToString() + ".txt"; } if (logtype == LogType.ERROR) { sFileName = LogDire + LogName_Error + "M" + DateTime.Now.Month.ToString() + "D" + DateTime.Now.Day.ToString() + ".txt"; } WriteLog(Msg, sFileName); } catch { } }
/// <summary> /// set a new or change an existing dispatching rule /// </summary> /// <param name="logger">target logger</param> /// <param name="logType">log entry type</param> /// <param name="logCategory">log entry category</param> /// <param name="caller">caller object</param> /// <param name="callerTypeName">caller type name</param> /// <param name="callerMemberName">caller member name</param> /// <param name="forwardEnabled">if true, the log action handled by the dispatcher is also forwarded to other dispatchers and to the logs pipeline. If not the dispatcher is the one handling the log action</param> /// <returns>the log dispatcher</returns> public ILogDispatcher SetDispatchingRule( ILog logger, LogType?logType = null, LogCategory?logCategory = null, object caller = null, string callerTypeName = null, string callerMemberName = null, bool forwardEnabled = true ) { var dispatcher = FilterValues .GetValue( caller, callerTypeName, callerMemberName, logType ?? LogType.NotDefined, logCategory ?? LogCategory.NotDefined ); if (dispatcher == null) { dispatcher = new Dispatcher(); } dispatcher .Loggers .AddLast(logger); FilterValues.AddOrSetValue( dispatcher, caller, callerTypeName, callerMemberName, logType, logCategory); return(this); }
internal DisposableTimer(ILogger logger, LogType logType, IProfiler profiler, Type loggerType, string startMessage, string endMessage) { if (logger == null) { throw new ArgumentNullException("logger"); } if (loggerType == null) { throw new ArgumentNullException("loggerType"); } _logger = logger; _logType = logType; _profiler = profiler; _loggerType = loggerType; _endMessage = endMessage; switch (logType) { case LogType.Debug: logger.Debug(loggerType, startMessage); break; case LogType.Info: logger.Info(loggerType, startMessage); break; default: throw new ArgumentOutOfRangeException("logType"); } if (profiler != null) { _profilerStep = profiler.Step(loggerType, startMessage); } }