public void Create_2_LogEntries_From_A_CollectionOfLines() { var loglines = new LogLines(); loglines.Add("[2020/09/16 09:50] iמʞαʞů (inkaku Capalini): cleaning out a desk is just not fun, hopefully their rearranging is beneficial for you lol"); loglines.Add("[2020/09/16 09:44] Rads (Radslns Hutchence): Good morning"); LogLoader target = new LogLoader(loglines); Assert.AreEqual(2, target.Lines.Count); }
public void Sort_LogEntries_BasedOn_Date() { var loglines = new LogLines(); loglines.Add("[2020/09/16 09:50] iמʞαʞů (inkaku Capalini): cleaning out a desk is just not fun, hopefully their rearranging is beneficial for you lol"); loglines.Add("[2020/09/16 09:44] Rads (Radslns Hutchence): Good morning"); LogLoader target = new LogLoader(loglines); var testvalue = target.SortedLines(); Assert.AreEqual("2020/09/16 09:44", testvalue.Values[0].getDateTime()); }
public void Sort_Two_LogEntries_For_The_Same_In_The_Order_They_Appear_In_TheLogs() { var loglines = new LogLines(); testline = "[2020/09/16 09:50] iמʞαʞů (inkaku Capalini): 2"; loglines.Add("[2020/09/16 09:50] iמʞαʞů (inkaku Capalini): cleaning out a desk is just not fun, hopefully their rearranging is beneficial for you lol"); loglines.Add(testline); loglines.Add("[2020/09/16 09:44] Rads (Radslns Hutchence): Good morning"); LogLoader target = new LogLoader(loglines); var testvalue = target.SortedLines(); Assert.AreEqual(testline, testvalue.Values[2].getLine()); }
public Task <TaskLog> CreateLogAsync(Guid scopeIdentifier, string hubName, Guid planId, TaskLog log, CancellationToken cancellationToken) { log.Id = LogObjects.Count + 1; LogObjects.Add(log.Id, log); LogLines.Add(log.Id, new List <string>()); return(Task.FromResult(log)); }
protected override Task <int> Handle(int lambdaEvent, MiddyNetContext context) { LogLines.Add(FunctionLog); ContextLogLines.AddRange(context.AdditionalContext.Select(kv => $"{kv.Key}-{kv.Value}")); Exceptions.AddRange(context.MiddlewareExceptions); return(Task.FromResult(0)); }
public Task <int> After(int lambdaResponse, MiddyNetContext context) { LogLines.Add($"{MiddlewareAfterLog}-{position}"); if (Failing) { throw new MiddlewareException(); } return(Task.FromResult(0)); }
public Task Before(int lambdaEvent, MiddyNetContext context) { LogLines.Add($"{MiddlewareBeforeLog}-{position}"); context.AdditionalContext.Add($"{ContextKeyLog}-{position}", $"{ContextLog}-{position}"); if (Failing) { throw new MiddlewareException(); } return(Task.CompletedTask); }
public async Task <Core.Model.ScanResult> DoScan() { Clear(); LogLines.Add(new Core.Model.LogLine() { Message = $"Started scan at {DateTime.Now.ToLongTimeString()}", Value = string.Empty, LogLineType = Core.Model.LogLineTypeEnum.Info }); BaseFolder = ScanOptions.BaseFolderPath; CheckBaseFolder(ScanOptions.BaseFolderPath); CancellationToken = new System.Threading.CancellationTokenSource(); Cancelled = false; var clock = new System.Diagnostics.Stopwatch(); clock.Restart(); var f = await Task.Run(() => ScanFolder(BaseFolder)); if (!Cancelled) { ScanResult.WambyFolderInfo = f; ScanResult.AllFolders = ScanResult.WambyFolderInfo.Folders. Where(p => p.IsFolder).SelectManyRecursive(p => p.Folders).ToList(); ScanResult.AllFolders.Add(ScanResult.WambyFolderInfo); if (ScanResult.WambyFolderInfo.Files.Count > 0) { ScanResult.AllFolders.Add(AddCurrentFolderFileSummary(ScanResult.WambyFolderInfo)); } var allfiles = ScanResult.AllFolders.SelectMany(p => p.Files); ScanResult.AllFiles.AddRange(allfiles); var totalDeepLenght = ScanResult.WambyFolderInfo.DeepLenght; var totalDeepFilesCount = ScanResult.WambyFolderInfo.DeepFilesCount; ScanResult.AllFolders.ForEach(p => { p.DeepLenghtPercent = p.DeepLenght / totalDeepLenght; p.DeepFilesCountPercent = p.DeepFilesCount / totalDeepFilesCount; }); } clock.Stop(); ScanResult.ElapsedTime = clock.Elapsed; LogLines.Add(new Core.Model.LogLine() { Message = $"Finished scan. Ellapsed time: {ScanResult.ElapsedTime.TotalSeconds.ToString("n2")} sec.", Value = string.Empty, LogLineType = Core.Model.LogLineTypeEnum.Info }); return(ScanResult); }
private void Log(string line) { Dispatcher.BeginInvoke(new Action(() => { // Add line to list LogLines.Add(line); // Scroll To Bottom if (VisualTreeHelper.GetChildrenCount(LogListBox) > 0) { Border border = (Border)VisualTreeHelper.GetChild(LogListBox, 0); ScrollViewer scrollViewer = (ScrollViewer)VisualTreeHelper.GetChild(border, 0); scrollViewer.ScrollToBottom(); } })); }
private void UpdateErrorReadingFileSystemInfoProgress(FileSystemInfo currentItem) { if (Cancelled) { return; } LogLines.Add(new Core.Model.LogLine() { Message = $"ERROR: {currentItem.FullName}", Value = currentItem.FullName, LogLineType = Core.Model.LogLineTypeEnum.Error }); ErrorReadingFileSystemInfoProgress?.Report(new Args.WambyFileSystemInfoEventArgs() { WambyFileSystemItem = currentItem }); }
private bool CheckIfCancellationRequested() { if (CancellationToken.IsCancellationRequested && !Cancelled) { Cancelled = true; var username = System.Security.Principal.WindowsIdentity.GetCurrent().Name; LogLines.Add(new Core.Model.LogLine() { Message = $"** Scan cancelled by user {username} **".ToUpper(), Value = string.Empty, LogLineType = Core.Model.LogLineTypeEnum.Error }); //CancelledByUserProgress?.Report(username); CancelledScan?.Invoke(this, new EventArgs()); return(true); } return(false); }
protected override void UpdateFromSelected() { try { this.LogLines?.Clear(); var content = File.ReadLines(Path.Combine(this.LogPath, this.SelectedLogFile)); foreach (var line in content) { LogLines.Add(new LogViewer.Log(line)); } } catch (Exception ex) { Log("Read log failed" + ex.Message, Category.Warn); LogLines?.Clear(); } }
// Jeder Aufruf des ViewModel targets wird ins ViewModel eingetragen. (Log Level Checks passieren ja schon im NLog Framework). private void LogViewModel(string level, string message) { NLog.LogLevel nl = NLog.LogLevel.FromString(level); Level myLev = FromNlogLevel(nl); Application.Current.Dispatcher.BeginInvoke( new Action(() => { if (LogLines.Count > C_MAXLINESINGUI) { LogLines.Clear(); LogLines.Add(new LogRecord() { Level = Level.Error, Message = $"******* GUI deleted Log lines after {C_MAXLINESINGUI} lines! *******" }); } LogLines.Add(new LogRecord() { Level = myLev, Message = message }); } )); }
private void UpdateScanningFolderProgress(Core.Model.WambyFolderInfo currentFolderInfo) { if (Cancelled) { return; } if (DetailType == Enums.ScanDetailTypeEnum.Detailed) { if (currentFolderInfo.Level <= ScanOptions.ShowMinimumFolderLevelInLog) { LogLines.Add(new Core.Model.LogLine() { Message = $"Reading: {currentFolderInfo.FullName}", Value = currentFolderInfo.FullName, LogLineType = Core.Model.LogLineTypeEnum.ReadingFolder }); ScanningFolderProgress?.Report(new Args.WambyFolderEventArgs() { WambyFolderInfo = currentFolderInfo }); } } else if (currentFolderInfo.Level <= 2) { LogLines.Add(new Core.Model.LogLine() { Message = $"Reading: {currentFolderInfo.FullName}", Value = currentFolderInfo.FullName, LogLineType = Core.Model.LogLineTypeEnum.ReadingFolder }); ScanningFolderProgress?.Report(new Args.WambyFolderEventArgs() { WambyFolderInfo = currentFolderInfo }); } }
private void LogLine(string text) { LogLines.Add(text); Console.WriteLine(text); }
private void AddLogLine(LogLine l) { Execute.OnUIThread(() => { LogLines.Add(l); }); }