internal BlockLogger(Log log, LogSeverity severity, string?blockName, Action <BlockLoggerParams>?fillParams, int callerLevel = 2) { isLoggingEnabled = GetIsLoggingEnabled(log, severity); if (!isLoggingEnabled) { return; } this.log = log; this.logMessage = GetLogMessageMethod(log, severity); this.blockName = blockName ?? (new StackFrame(callerLevel, false)?.GetMethod()?.Name ?? "Block name not found."); this.fillResults = null; //Log the start string baseMessage = String.Format("Entered method: '{0}'", this.blockName); if (fillParams != null) { var bp = new BlockLoggerParams(log); fillParams(bp); baseMessage += " with parameters: " + bp.Text; } logMessage(baseMessage); }
/// <summary> /// Shows info on all notifications associated with some account. Uses {accountSid} from configuration in HttpProvider /// </summary> /// <param name="log">Specifies that only notifications with the given log level value should be listed. Allowed values are 1,2 or 3, where 2=INFO, 1=WARNING, 0=ERROR.</param> /// <param name="page">Used to return a particular page within the list.</param> /// <param name="pageSize">Used to specify the amount of list items to return per page.</param> /// <returns>Returns notification list</returns> public NotificationsList ListNotifications(Log?log = null, int?page = null, int?pageSize = null) { // Get account sid from configuration var accountSid = HttpProvider.GetConfiguration().AccountSid; return(this.ListNotifications(accountSid, log, page, pageSize)); }
/// <summary> /// String to JToken /// </summary> /// <param name="stringData"></param> /// <param name="log"></param> /// <returns></returns> public static JToken?ToJToken(this string stringData, Log?log = null) { if (string.IsNullOrEmpty(stringData)) { return(null); } try { return(JToken.Parse(stringData)); } catch (JsonReaderException jre) { var info = $"Deserialize JsonReaderException: {jre.Message}, Path: {jre.Path}, LineNumber: {jre.LineNumber}, LinePosition: {jre.LinePosition}. Data: {stringData}"; log?.Write(LogVerbosity.Error, info); if (log == null) { Debug.WriteLine(info); } return(null); } catch (JsonSerializationException jse) { var info = $"Deserialize JsonSerializationException: {jse.Message}. Data: {stringData}"; log?.Write(LogVerbosity.Error, info); if (log == null) { Debug.WriteLine(info); } return(null); } }
public async Task Run(Context context, Log?log = null) { if (log != null) { Log = log; } foreach (Step step in Steps) { context.Banner(step.Description ?? step.GetType().FullName); bool success; Exception?stepEx = null; try { success = await step.Run(context); } catch (Exception ex) { stepEx = ex; success = false; } if (success) { continue; } string message = $"Step {step.FailedStep ?? step} failed"; if (stepEx != null) { throw new InvalidOperationException($"{message}: {stepEx.Message}", stepEx); } else { throw new InvalidOperationException(message); } } }
public void Simplification(Log?log = null, bool swapConstantsToLeaf = true) { if (LeafsCount > 0) { for (var i = 0; i < LeafsCount; i++) { Genotype = Genotype.Replace("Leaf[" + i + "]", SurvivalRate.Constants[i].ToString(CultureInfo.InvariantCulture)); } Genotype = Genotype.Replace("+-", "-").Replace("--", "+"); } var synanthicTree = new TreeParser(Genotype); synanthicTree.Parse(); synanthicTree.Simplification(); if (swapConstantsToLeaf) { SurvivalRate.Constants = synanthicTree.ChangeConstantsToLeaf(); } LeafsCount = SurvivalRate.Constants.Length; string simlificated = synanthicTree.ReparseTree(); Genotype = simlificated; if (log == null) { return; } ((Log)log).Simplification.Add(":Gen: " + Genotype); ((Log)log).Simplification.Add(":End: " + Genotype); }
/// <summary> /// String to JToken /// </summary> /// <param name="stringData"></param> /// <param name="log"></param> /// <returns></returns> public static JToken?ToJToken(this string stringData, Log?log = null) { if (string.IsNullOrEmpty(stringData)) { return(null); } try { return(JToken.Parse(stringData)); } catch (JsonReaderException jre) { var info = $"Deserialize JsonReaderException: {jre.Message}, Path: {jre.Path}, LineNumber: {jre.LineNumber}, LinePosition: {jre.LinePosition}. Data: {stringData}"; log?.Write(LogLevel.Error, info); if (log == null) { Trace.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss:fff} | Warning | {info}"); } return(null); } catch (JsonSerializationException jse) { var info = $"Deserialize JsonSerializationException: {jse.Message}. Data: {stringData}"; log?.Write(LogLevel.Error, info); if (log == null) { Trace.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss:fff} | Warning | {info}"); } return(null); } }
public Log?GetAndUnset() { Log log = TargetLog !; TargetLog = null; return(log); }
public MSBuildRunner(Context context, Log?log = null, string?msbuildPath = null) : base(context, log, msbuildPath) { ProcessTimeout = TimeSpan.FromMinutes(30); StandardArguments = new List <string> { $"/p:Configuration={context.Configuration}", }; }
public MakeRunner(Context context, Log?log = null, string?makePath = null) : base(context, log, makePath) { ProcessTimeout = TimeSpan.FromMinutes(60); string vs = VersionString.Trim(); if (String.IsNullOrEmpty(vs) || !Version.TryParse(vs, out version)) { version = new Version(0, 0); } }
public async static Task <Log> InitializeAsync(Guid id) { if (_instance is not null) { throw new InvalidOperationException(); } _instance = new Log(await Pipe.StartServerAsync(Pipe.LogName, id, bidirectional: false, cancellationToken: default).ConfigureAwait(false)); await _instance._WriteLineAsync("").ConfigureAwait(false); return(_instance); }
public SevenZipRunner(Context context, Log?log = null, string?toolPath = null) : base(context, log, toolPath ?? Context.Instance.Tools.SevenZipPath) { ProcessTimeout = TimeSpan.FromMinutes(DefaultTimeout); string vs = VersionString.Trim(); if (String.IsNullOrEmpty(vs) || !Version.TryParse(vs, out version)) { version = new Version(0, 0); } }
/// <summary> /// Sets the parameters for list notifications. /// </summary> /// <param name="request">The request.</param> /// <param name="log">The log.</param> /// <param name="page">The page.</param> /// <param name="pageSize">Size of the page.</param> private void SetParamsForListNotifications(IRestRequest request, Log?log, int?page, int?pageSize) { if (log != null) { request.AddQueryParameter("Log", ((int)log.Value).ToString()); } if (page != null) { request.AddQueryParameter("Page", page.ToString()); } if (pageSize != null) { request.AddQueryParameter("PageSize", pageSize.ToString()); } }
public static IReadOnlyCollection <LogLevel> GetEnabledLevels() { var logs = new Log?[] { Debug, Info, Warning, Error, Guest, AccessLog, Stub }; List <LogLevel> levels = new List <LogLevel>(logs.Length); foreach (var log in logs) { if (log.HasValue) { levels.Add(log.Value.Level); } } return(levels); }
public void Invoke(Log targetLog) { Console.Write("Invoked: " + targetLog.Question); TargetLog = targetLog; if (targetLog.Action.StartsWith("pass.")) { Console.WriteLine(" -> blacklist"); NavigationManager.NavigateTo("/blacklist"); } else if (targetLog.Action.StartsWith("block.")) { Console.WriteLine(" -> whitelist"); NavigationManager.NavigateTo("/whitelist"); } }
private void OnNewLog(Log?v) { if (_clientRole == UserRole.Roles.Undefined && (v == null || v.Client != ClientIP)) { return; } if (v != null) { _queryLogTable !.PrependRow(v, 1000); } else { _queryLogTable !.InvalidateData(); } }
public bool Equals(Log?other) { if (other == null) { return(false); } return ((this.StartTime == other.StartTime) && (this.EndTime == other.EndTime) && (this.EditTime == other.EditTime) && (this.Comments == other.Comments) && (this.Technique == other.Technique) && (this.Latitude == other.Latitude) && (this.Longitude == other.Longitude)); }
public async Task <Text?> GetLastReadAsync(string userName) { Log?log = await this.logRepository.Queryable() .Where(l => l.UserName == userName && l.Event == Constants.TextReadEvent) .OrderByDescending(l => l.Id) .FirstOrDefaultAsync(); if (log is null) { return(null); } Text text = await this.textRepository.GetByIdAsync(log.EntityId !.Value); return(text); }
/// <summary> /// Shows info on all notifications associated with some account /// </summary> /// <param name="accountSid">The account sid.</param> /// <param name="log">Specifies that only notifications with the given log level value should be listed. Allowed values are 1,2 or 3, where 2=INFO, 1=WARNING, 0=ERROR.</param> /// <param name="page">Used to return a particular page within the list.</param> /// <param name="pageSize">Used to specify the amount of list items to return per page.</param> /// <returns>Returns notification list</returns> public NotificationsList ListNotifications(string accountSid, Log?log = null, int?page = null, int?pageSize = null) { // Get client to make request var client = HttpProvider.GetHttpClient(); // Create GET request var request = RestRequestHelper.CreateRestRequest(Method.GET, $"Accounts/{accountSid}/Notifications.json"); // Add ListNotifications query and body parameters this.SetParamsForListNotifications(request, log, page, pageSize); // Send request var response = client.Execute(request); return(this.ReturnOrThrowException <NotificationsList>(response)); }
protected ToolRunner(Context context, Log?log = null, string?toolPath = null) : base(log) { Context = context ?? throw new ArgumentNullException(nameof(context)); if (String.IsNullOrEmpty(toolPath)) { Log.DebugLine($"Locating {ToolName} executable '{DefaultToolExecutableName}'"); FullToolPath = context.OS.Which(DefaultToolExecutableName); } else { Log.DebugLine($"Custom NuGet path: {toolPath}"); if (toolPath !.IndexOf(Path.DirectorySeparatorChar) < 0) { Log.DebugLine($"Locating custom {ToolName} executable '{toolPath}'"); FullToolPath = context.OS.Which(toolPath); }
protected SubscriptionService( StreamStoreBase streamStoreClient, string subscriptionName, ICheckpointStore checkpointStore, IJsonEventSerializer eventSerializer, IEnumerable <IEventHandler> projections, ILoggerFactory?loggerFactory = null, ProjectionGapMeasure?measure = null ) { StreamStoreClient = streamStoreClient; _checkpointStore = checkpointStore; _eventSerializer = eventSerializer; _subscriptionName = subscriptionName; _measure = measure; _projections = projections.Where(x => x.SubscriptionGroup == subscriptionName).ToArray(); _log = loggerFactory?.CreateLogger($"StreamSubscription-{subscriptionName}"); _debugLog = _log?.IsEnabled(LogLevel.Debug) == true ? _log.LogDebug : null; }
protected override void OnInitialized() { _clientRole = Utility.GetRole(AuthenticationStateTask ?? throw new ArgumentNullException()).Result; _newRule = new Infrastructure.Schema.Whitelist(); if (_clientRole != UserRole.Roles.Privileged && _clientRole != UserRole.Roles.Administrator) { throw new Exception(); } Log?fromLog = LogActionService.GetAndUnset(); if (fromLog != null) { Console.WriteLine("From log: " + fromLog.Question); string pattern = @"(?:^|.+\.)" + fromLog.Question.Replace(".", @"\.") + "$"; Rule().Pattern = pattern; } InitValidators(); InitInputs(); // _whitelistTable = new FlareTable <Infrastructure.Schema.Whitelist>( () => _clientRole == UserRole.Roles.Privileged ? WhitelistModel.List(ClientIP !) : WhitelistModel.List(), sessionStorage: SessionStorageService, identifier: "Rules.WhitelistTable", monospace: true); _whitelistTable.RegisterColumn(nameof(Infrastructure.Schema.Whitelist.ID)); _whitelistTable.RegisterColumn(nameof(Infrastructure.Schema.Whitelist.Pattern)); _whitelistTable.RegisterColumn(nameof(Infrastructure.Schema.Whitelist.Expires)); _whitelistTable.RegisterColumn("_Edit", sortable: false, filterable: false, displayName: "", width: "56px"); _whitelistTable.RegisterColumn("_Remove", sortable: false, filterable: false, displayName: "", width: "82px"); _whitelistTable.OnRowClick += whitelist => { }; BuildHeaders(); }
protected SubscriptionService( EventStoreClient eventStoreClient, string subscriptionId, ICheckpointStore checkpointStore, IEventSerializer eventSerializer, IEnumerable<IEventHandler> eventHandlers, ILoggerFactory? loggerFactory = null, SubscriptionGapMeasure? measure = null ) { EventStoreClient = eventStoreClient; _checkpointStore = checkpointStore; _eventSerializer = eventSerializer; _subscriptionId = subscriptionId; _measure = measure; _projections = eventHandlers.Where(x => x.SubscriptionId == subscriptionId).ToArray(); _log = loggerFactory?.CreateLogger($"StreamSubscription-{subscriptionId}"); _debugLog = _log?.IsEnabled(LogLevel.Debug) == true ? _log.LogDebug : null; }
protected SubscriptionService( string subscriptionId, ICheckpointStore checkpointStore, IEventSerializer eventSerializer, IEnumerable <IEventHandler> eventHandlers, ILoggerFactory?loggerFactory = null, ISubscriptionGapMeasure?measure = null ) { _checkpointStore = Ensure.NotNull(checkpointStore, nameof(checkpointStore)); _eventSerializer = Ensure.NotNull(eventSerializer, nameof(eventSerializer)); SubscriptionId = Ensure.NotEmptyString(subscriptionId, subscriptionId); _measure = measure; _eventHandlers = Ensure.NotNull(eventHandlers, nameof(eventHandlers)) .Where(x => x.SubscriptionId == subscriptionId) .ToArray(); _log = loggerFactory?.CreateLogger($"StreamSubscription-{subscriptionId}"); _debugLog = _log?.IsEnabled(LogLevel.Debug) == true ? _log.LogDebug : null; }
public RegexProgramVersionParser(string programName, string versionArguments, string regex, uint versionOutputLine = 0, Log?log = null) : base(programName, versionArguments, versionOutputLine, log) { if (String.IsNullOrEmpty(regex)) { throw new ArgumentException("must not be null or empty", nameof(regex)); } rx = new Regex(regex, RegexOptions.Compiled); }
public NuGetRunner(Context context, Log?log = null, string?nugetPath = null) : base(context, log, nugetPath ?? Configurables.Paths.LocalNugetPath) { }
protected ProgramVersionParser(string programName, string?versionArguments = null, uint versionOutputLine = 0, Log?log = null) : base(log) { if (String.IsNullOrEmpty(programName)) { throw new ArgumentException("must not be null or empty", nameof(programName)); } ProgramName = programName; VersionArguments = versionArguments; VersionOutputLine = versionOutputLine; }
public SnRunner(Context context, Log?log = null, string?snPath = null) : base(context, log, snPath) { }
public static void Add(this Dictionary <string, ProgramVersionParser> dict, string programName, string versionArguments, Regex regex, uint versionOutputLine = 0, Log?log = null) { if (dict.ContainsKey(programName)) { Log.Instance.WarningLine($"Entry for {programName} version matcher already defined. Ignoring the new entry ({regex})"); return; } dict [programName] = new RegexProgramVersionParser(programName, versionArguments, regex, versionOutputLine, log); }
public TarRunner(Context context, Log?log = null, string?toolPath = null) : base(context, log, toolPath) { }
public GitRunner(Context context, Log?log = null, string?gitPath = null) : base(context, log, gitPath ?? context.Tools.GitPath) { ProcessTimeout = TimeSpan.FromMinutes(30); }