public void Data_Stream_Serially_Count_AndStartOffset_MoreThanAvailable_SinglePage() { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); parameters.Count = expected.Count * 2; StreamLogsSerial(parameters, expected.ToList()); }
public void LogParameters_SetsStartAndEnd_InConstructor() { var start = DateTime.Now; var end = DateTime.Now.AddDays(1); var parameters = new LogParameters(null, start, end); Assert.AreEqual(start.ToString(), parameters.StartDate.ToString(), "Start was not correct"); Assert.AreEqual(end.ToString(), parameters.EndDate.ToString(), "End was not correct"); }
public void Data_Stream_Parallel_WithStartOffset_MultiplePages() { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); parameters.PageSize = 50; StreamLogs(parameters, expected); }
public void Data_Stream_Parallel_Count_AndStartOffset_SinglePage() { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); parameters.Count = 10; StreamLogs(parameters, expected.Take(10).ToList()); }
private void LogHistory(LogParameters parameters) { var token = GetToken(); token = token.Replace("Bearer ", string.Empty); var url = _configuration.HistoryServiceUrl + "api/history/book"; _bookActionLogger.LogBookAction(token, parameters, url); }
public void LogBatch(Log.PriorityFlags logLevel, StructuredLogObject logObject, LogChannelType channel = LogChannelType.Default) { if (!clubPenguinClient.OfflineMode) { LogParameters logParameters = new LogParameters(); logParameters.logName = channel.ToString(); logParameters.severity = logLevelsToString[logLevel]; logParameters.message = Service.Get <JsonService>().Serialize(logObject); logParametersList.Add(logParameters); } }
public async Task <ActionResult <PaginatedResult <LinLogResource> > > GetAllLogs( [FromQuery] LogParameters logParameters) { var list = await _linLogRepository.GetAllLogsAsync(logParameters); var resources = MyMapper.Map <IEnumerable <LinLog>, IEnumerable <LinLogResource> >(list); var result = WrapPaginatedResult(list, resources); return(Ok(result)); }
public void Data_StreamLogs_WithIncorrectPageSize() { FilterTests.Retry(retry => { var correctParameters = new LogParameters(null, RecordAge.Today, 15) { PageSize = 5 }; var automaticParameters = new LogParameters(null, RecordAge.Today, 15) { Start = 0, PageSize = 5 }; var manualParameters = new LogParameters(null, RecordAge.Today, 5) { Start = 0 }; //The real logs that exist on the server. This is what all other requests compare against var correctLogs = client.GetLogs(correctParameters); //What we get when we make the same request with a starting index of 0. We expect GetLogs to return //something equivalent to a normal request, but StreamSensors to contain a duplicate at index 4 and 5 var automaticLogs = client.GetLogs(automaticParameters); var automaticStreamLogs = client.StreamLogs(automaticParameters, true).ToList(); //What we get when we manually increment the pages of a stream. We expect to end up with a list //identical to our streamed list var firstManualLogs = client.GetLogs(manualParameters); manualParameters.Page++; var secondManualLogs = client.GetLogs(manualParameters); manualParameters.Page++; var thirdManualLogs = client.GetLogs(manualParameters); var allManualLogs = new List <Log>(); allManualLogs.AddRange(firstManualLogs); allManualLogs.AddRange(secondManualLogs); allManualLogs.AddRange(thirdManualLogs); var comparer = PrtgAPIHelpers.LogEqualityComparer(); AssertEx.AreEqualLists(correctLogs, automaticLogs, comparer, "Correct logs were not equal to off by one logs", retry); AssertEx.AreEqualLists(automaticStreamLogs, allManualLogs, comparer, "Streamed off by one logs were not equal to manual logs", retry); Assert.IsTrue(comparer.Equals(automaticStreamLogs[4], automaticStreamLogs[5])); Assert.IsTrue(comparer.Equals(allManualLogs[4], allManualLogs[5])); //now check none of the OTHER elements are equal to each other var automaticDiff = automaticStreamLogs.Where((l, i) => i != 4 && i != 5).ToList(); var manualDiff = allManualLogs.Where((l, i) => i != 4 && i != 5).ToList(); AssertEx.AllListElementsUnique(automaticDiff, comparer); AssertEx.AllListElementsUnique(manualDiff, comparer); }); }
public void Data_Stream_Serially_Count_AndStartOffset_MultiplePages() { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); parameters.PageSize = 5; parameters.Count = 10; StreamLogsSerial(parameters, expected.Take(10).ToList()); }
public void Data_Stream_Parallel_Count_AndStartOffset_MoreThanAvailable_MultiplePages() { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); parameters.Count = expected.Count; parameters.PageSize = 507; StreamLogsSerial(parameters, expected.ToList()); }
public void Data_Stream_Serially_Start_AndStartOffset_SinglePage() { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); var start = 3; parameters.Start = start; StreamLogsSerial(parameters, expected.Skip(start - 1).ToList()); }
public void Data_Stream_Parallel_StartAndCount_AndStartOffset_CountMoreThanAvailable_SinglePage() { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); var start = 4; parameters.Count = expected.Count * 2; parameters.Start = start; StreamLogs(parameters, expected.Skip(start - 1).ToList()); }
internal override void LogWrite(LogParameters logInfo) { var serializer = new CsvSerializer <LogParameters>(); try { serializer.Serialize(logFilePath, logInfo); } catch (System.Exception) { Console.WriteLine($"DumbLogger. Error, log was not written into log file : {logFilePath}"); throw; } }
/// <summary> /// build a new repeater logger initialized with logger list /// </summary> /// <param name="logParameters"></param> public Repeater( List <ILog> loggers, LogParameters logParameters = null) : base(logParameters) { if (loggers == null) { throw new ArgumentNullException(nameof(loggers)); } foreach (var o in loggers) { Loggers.AddLast(o); } }
public void Data_Stream_Parallel_Count_AndStartOffset_LessThanAvailable_SinglePage() { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); var count = 100; Assert.IsTrue(count < expected.Count); parameters.Count = count; StreamLogs(parameters, expected.Take(count).ToList()); }
public void Data_Stream_Serially_StartAndCount_AndStartOffset_CountMoreThanAvailable_MultiplePages() { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); var start = 8; parameters.Count = expected.Count * 2; parameters.Start = start; parameters.PageSize = 50; StreamLogsSerial(parameters, expected.Skip(start - 1).ToList()); }
public void LogImmediate(Log.PriorityFlags logLevel, StructuredLogObject logObject, LogChannelType channel = LogChannelType.Default) { if (!clubPenguinClient.OfflineMode) { LogParameters logParameters = new LogParameters(); logParameters.logName = channel.ToString(); logParameters.severity = logLevelsToString[logLevel]; logParameters.message = Service.Get <JsonService>().Serialize(logObject); logParametersList.Add(logParameters); APICall <PostDiagnosticsLogOperation> aPICall = PostDiagnosticsLog(logParametersList); aPICall.OnComplete += onPostDiagnosticsLog; aPICall.Execute(); } }
/// <summary> /// build a new file logger /// </summary> /// <param name="fileLogParameters">file log parameters</param> /// <param name="logParameters">log parameters</param> public FileLog( FileLogParameters fileLogParameters, LogParameters logParameters = null ) : base(logParameters) { FileLogParameters = fileLogParameters; if (FileLogParameters.IsDefered) { LogParameters .LogItemBuffer .ItemRangeAdded += LogItemBuffer_ItemRangeAdded; } }
public void Data_Stream_Parallel_StartAndCount_AndStartOffset_MultiplePages() { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); var count = 10; var start = 8; parameters.Count = count; parameters.Start = start; parameters.PageSize = 5; StreamLogs(parameters, expected.Skip(start - 1).Take(count).ToList()); }
/// <summary> /// build a new repeater logger initialized with logger list /// </summary> /// <param name="loggers">loggers to dispatch to</param> /// <param name="isDispatcherFilterEnabled">if true, the dispatcher check its own filtering rules, else only loggers filters are checked for filtered log actions</param> /// <param name="logParameters"></param> public Dispatcher( List <ILog> loggers, bool isDispatcherFilterEnabled = true, LogParameters logParameters = null) : base(logParameters) { if (loggers == null) { throw new ArgumentNullException(nameof(loggers)); } this.IsDispatcherFilterEnabled = isDispatcherFilterEnabled; foreach (var o in loggers) { Loggers.AddLast(o); } }
public void Data_Stream_Parallel_Start_AndStartOffset_MultiplePages() { FilterTests.Retry(retry => { var parameters = new LogParameters(Settings.UpSensor, RecordAge.Today, null); var expected = client.GetLogs(parameters); var start = 130; parameters.Start = start; parameters.PageSize = 50; StreamLogs(parameters, expected.Skip(start - 1).ToList(), retry); }); }
public void Data_Stream_Serially_StartAndCount_AndStartOffset_CountLessThanAvailable_SinglePage() { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); var count = 10; var start = 4; parameters.Count = count; parameters.Start = start; Assert.IsTrue(parameters.Count < expected.Count); StreamLogsSerial(parameters, expected.Skip(start - 1).Take(count).ToList()); }
public async Task <PaginatedList <LinLog> > GetAllLogsAsync(LogParameters logParameters) { var query = _linContext.LinLogs .AsQueryable(); query = BuildQueryForLinLogs(logParameters, query); var total = await query.CountAsync(); var data = await query .Skip(logParameters.Start + logParameters.Page *logParameters.Count) .Take(logParameters.Count) .ToListAsync(); return(new PaginatedList <LinLog>(logParameters.Page, logParameters.Count, total, data)); }
private void StreamLogs(LogParameters parameters, string[] address, int count = 10) { var url = new List <string>(); url.Add(TestHelpers.RequestLog($"count=1&columns=objid,name", null)); url.AddRange(address.Select(a => TestHelpers.RequestLog(a, UrlFlag.Columns))); Execute( c => c.StreamLogs(parameters).ToList(), url.ToArray(), new Dictionary <Content, int> { [Content.Logs] = count } ); }
/// <summary> /// build a new pipe socket server allowing to dispatch log items over the network /// <para>Exceptions:</para> /// <para>The combination of addressFamily, socketType, and protocolType results in an invalid socket</para> /// </summary> /// <param name="socketServerContext">server context settings</param> /// <param name="logParameters">log parameters</param> /// <param name="debugLog">private debug logger for debug purposes</param> /// <param name="isDebugLogEnabled">enabled/disable server private logger</param> public WinsockServer( WinsockServerContext socketServerContext = null, LogParameters logParameters = null, ILog debugLog = null, bool isDebugLogEnabled = true ) : base(logParameters) { this.DebugLog = debugLog; this.IsDebugLogEnabled = isDebugLogEnabled; this.SocketServerContext = socketServerContext ?? new WinsockServerContext(); if (IsDebugLogEnabled) { DebugLog.Debug(LogCategory.Network) ?.T($"starting pipe winsock logger server on port {SocketServerContext.PortNumber}"); } ConnectionListenerTask = Task.Run(() => StartListening()); }
public void Data_Stream_Parallel_Count_AndStartOffset_LessThanAvailable_SinglePage() { FilterTests.Retry(retry => { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); var count = 100; AssertEx.IsTrue(count < expected.Count, $"Expected {count} to be less than {expected.Count}"); parameters.Count = count; StreamLogs(parameters, expected.Take(count).ToList()); }); }
public void Data_Stream_Serially_Count_AndStartOffset_LessThanAvailable_MultiplePages() { FilterTests.Retry(retry => { var parameters = new LogParameters(Settings.UpSensor, RecordAge.All, null); var expected = client.GetLogs(parameters); var count = 100; Assert.IsTrue(count < expected.Count); parameters.Count = count; parameters.PageSize = 30; StreamLogsSerial(parameters, expected.Take(count).ToList()); }); }
public async Task <IActionResult> PageLogData(LogParameters parameters) { var data = await _sysLogService.GetAllLogsAsync(parameters); var res = _mapper.Map <IEnumerable <SysLogViewModel> >(data); var shapedLogResources = res.ToDynamicIEnumerable(parameters.Fields); var jsonRes = new { code = 0, message = "", count = data.TotalItemsCount, data = shapedLogResources }; LogInformation("查询日志信息列表"); return(Json(jsonRes)); }
public async Task <IActionResult> Edit(int id) { var token = HttpContext.Session.GetString("Token"); if (token == null) { return(RedirectToAction("Login", "FrontAuth")); } var response = await _client.GetProtectedAsync2 <ProjectMatrixTypeUpdateGet>($"{_configuration["APIUrl"]}api/ProjectMatrixType/Update/" + id, token); ViewBag.UITerms = await _client.GetProtectedAsync <List <UITermLanguageCustomizationList> >($"{_configuration["APIUrl"]}api/MVC/ProjectMatrixType/Edit", token); var x = new LogParameters() { ActionName = "Edit", ControllerName = "ProjectMatrixType", IsIntRecordId = true, IntRecordId = id, StringRecordId = "" }; ViewBag.ReadLogView = await _client.PostProtectedAsync <List <ReadLogGet> >($"{_configuration["APIUrl"]}api/Log/ReadLogView", x, token); ViewBag.ChangeLogView = await _client.PostProtectedAsync <List <ChangeLogGet> >($"{_configuration["APIUrl"]}api/Log/ChangeLogView", x, token); ViewBag.Favorites = await _client.GetProtectedAsync <List <MVCFavoriteMenu> >($"{_configuration["APIUrl"]}api/MVCFavorite/Menu", token); ViewBag.FavoriteGroupList = await _client.GetProtectedAsync <List <MVCFavoriteGroupList> >($"{_configuration["APIUrl"]}api/MVCFavorite/GroupList", token); ViewBag.Env = _hostingEnv.EnvironmentName; ViewBag.ErrorMessages = new List <ErrorMessage>(); var tool = new { tooltipText = "Multiple Image upload", template = "<button type='button' class='e-tbar-btn e-btn' tabindex='-1' id='custom_tbar' style='width:100%'><div class='e-tbar-btn-text rtecustomtool' style='font-weight: 500;'>Multiple upload</div></button>" }; ViewBag.items = new object[] { "Bold", "Italic", "Underline", "Formats", "Alignments", "OrderedList", "UnorderedList", "Image", "|", tool, "SourceCode", "Undo", "Redo" }; if (response.Item2 == true) { return(View(response.Item1)); } else { return(RedirectToAction("Menu", "Admin")); } }
private void StreamLogsSerial(LogParameters parameters, string[] address, bool requestCount, int count = 10) { var url = new List <string>(); if (requestCount) { url.Add(UnitRequest.Logs($"count=1&columns=objid,name", null)); } url.AddRange(address.Select(a => UnitRequest.Logs(a, UrlFlag.Columns))); Execute( c => c.StreamLogs(parameters, true).ToList(), url.ToArray(), new Dictionary <Content, int> { [Content.Logs] = count } ); }