public void Ctor_DeclareLogObjectWithNullOutput_ExceptionThrown() { ILogOutput outLog = null; ILogEntryFormatter entryFormatter = new FileFormatter(); Assert.Throws <ArgumentNullException>(() => new Log(outLog, entryFormatter)); }
static Log() { prefixedLogs = new Dictionary <string, ILogOutput>(); prefixedLogsLock = new object(); outLock = new object(); output = new LogConsoleOutput(); }
private void AddEntry(LogEntry entry, object context) { // Check whether the message contains null characters. If it does, crop it, because it's probably broken. int nullCharIndex = entry.Message.IndexOf('\0'); if (nullCharIndex != -1) { entry.Message = entry.Message .Substring(0, Math.Min(nullCharIndex, 50)) + " | Contains '\0' and is likely broken."; } // Forward the message to all outputs lock (_outputLock) { for (int i = 0; i < _outputs.Count; i++) { ILogOutput log = _outputs[i]; try { log.Write(this, entry, context); } catch (Exception) { // Don't allow log outputs to throw unhandled exceptions, // because they would result in another log - and more exceptions. } } } }
public static void SetLogOutput(ILogOutput log, LogSeverity minSeverity = LogSeverity.Info) { Debug.Assert(LogOutput == null); LogOutput = log; MinSeverity = minSeverity; }
/// <summary> /// Underlying method actually called through to by the Matches(Object) method /// /// Simply tries to check if anything has been logged at a level above the minimum threshold specified /// </summary> /// <param name="logOutput_"></param> /// <returns></returns> public bool Matches(ILogOutput logOutput_) { var logLevelNames = Enum.GetNames(typeof(LogLevel)); foreach (var logLevelName in logLevelNames) { var logLevel = LogLevelExtensions.Parse(logLevelName); if (ThresholdLogLevel >= logLevel) { continue; } if (!logOutput_.LogMessages[logLevel].Any()) { continue; } _errorMessage.Append("Log output contains messages logged at level ["); _errorMessage.Append(logLevel.ToLogString()); _errorMessage.Append("] when no messages above level ["); _errorMessage.Append(ThresholdLogLevel.ToLogString()); _errorMessage.Append("] were expected"); return(false); } return(true); }
public ImageStore(IClusterConnection clusterConnection, ILogOutput logger) : base(clusterConnection, logger) { retryPolicy = Policy .HandleResult <HttpResponseMessage>(r => !r.IsSuccessStatusCode) .WaitAndRetryAsync(5, i => TimeSpan.FromSeconds(Math.Pow(2, i))); }
/// <summary> /// Removes a certain output. /// </summary> /// <param name="writer"></param> public void RemoveOutput(ILogOutput writer) { lock (this.syncObj) { this.output.Remove(writer); this.syncOutput = this.output.ToArray(); } }
public AssignmentGraphIndexer(IInstructionParser instructionParser, ITripleStore tripleStore, ILogOutput logOutput) { _instructionParser = instructionParser; _tripleStore = tripleStore; _logOutput = logOutput; }
public static void RemoveGlobalOutput(ILogOutput output) { _globalLogOutput.Remove(output); foreach (Log log in All) { log.RemoveOutput(output); } }
/// <summary> /// Adds an output to write log entries to. /// </summary> /// <param name="writer"></param> public void AddOutput(ILogOutput writer) { lock (this.syncObj) { this.output.Add(writer); this.syncOutput = this.output.ToArray(); } }
public CallTreeWalker(IMethodIndexer methodIndexer, IDatabaseResolver databaseResolver, ILogOutput logOutput) { _methodIndexer = methodIndexer; _databaseResolver = databaseResolver; _logOutput = logOutput; _methodNodeLookup = new Dictionary <string, MethodNode>(); }
public ConcurrentLogger(ApplicationLevel applicationLevel, ILogOutput output) { ContractAssertions.IsNotNull(output, nameof(output)); _output = output; _applicationLevel = applicationLevel; _enqueueMessage = false; }
/// <summary> /// Internal to make it accessable to unittests. Don't use this constructor unless you know what you're doing! /// </summary> /// <param name="logOutput"></param> /// <param name="logFormatter"></param> internal Log(ILogOutput logOutput, ILogEntryFormatter logFormatter) { if (logOutput == null || logFormatter == null) { throw new ArgumentNullException("Log Output parameter or Formatter parameter is null."); } _logOutput = logOutput; _logFormatter = logFormatter; }
public void PopIndent() { lock (_outputLock) { for (int i = 0; i < _outputs.Count; i++) { ILogOutput log = _outputs[i]; try { log.PopIndent(); } catch (Exception) {} } } }
/// <summary> /// Removes the specified <see cref="ILogOutput"/> from every log global channel. /// </summary> /// <param name="output"></param> public static void RemoveGlobalOutput(ILogOutput output) { lock (syncObj) { globalOutput.Remove(output); syncOutput = globalOutput.ToArray(); foreach (Log log in logs) { log.RemoveOutput(output); } } }
/// <summary> /// Adds the specified <see cref="ILogOutput"/> to every log global channel. /// </summary> /// <param name="output"></param> public static void AddGlobalOutput(ILogOutput output) { lock (syncObj) { globalOutput.Add(output); syncOutput = globalOutput.ToArray(); foreach (Log log in logs) { log.AddOutput(output); } } }
public static void AddGlobalOutput(ILogOutput output) { if (_globalLogOutput.Contains(output)) { return; } _globalLogOutput.Add(output); foreach (Log log in All) { log.AddOutput(output); } }
public static void RegisterLogOutput(ILogOutput output, string logCategory) { if (CategoryOutputs.ContainsKey(logCategory) == false) { CategoryOutputs[logCategory] = new List <ILogOutput>(); } List <ILogOutput> outputs = CategoryOutputs[logCategory]; if (outputs.Contains(output) == false) { outputs.Add(output); } }
static Logger() { _logOutput = new ConsoleLogOutput(); AppDomain.CurrentDomain.UnhandledException += (sender, args) => Error(args.ExceptionObject); #if DEBUG _debugEnabled = true; LogCallingMethod = true; #else _debugEnabled = false; // can be set via property LogCallingMethod = false; #endif singleThreaded = true; Initialize(); }
public AnalysisEngine(IAssignmentGraphIndexer assignmentGraphIndexer, IAssignmentGraphWalker assignmentGraphWalker, IMethodIndexer methodIndexer, IDelegateIndexer delegateIndexer, ICallTreeWalker callTreeWalker, ITypeService typeService, ILogOutput logOutput) { _assignmentGraphIndexer = assignmentGraphIndexer; _assignmentGraphWalker = assignmentGraphWalker; _methodIndexer = methodIndexer; _delegateIndexer = delegateIndexer; _callTreeWalker = callTreeWalker; _typeService = typeService; _logOutput = logOutput; }
public static void Obfuscate(AssemblyDefinition assembly, ILogOutput logOutput) { StartupSettings(); logOutput.WriteMessage("Obfuscator module written by Marwix (2016)."); logOutput.WriteMessage("---------------------------------------------------"); var startTime = DateTime.Now; logOutput.WriteMessage("Started obfuscation process at " + startTime); var context = new ObfuscationContext(assembly, logOutput); var tasks = new ObfuscatorTask[] { new JunkCodeGenerationTask(), new SymbolRenamingTask(), }; foreach (var task in tasks) { logOutput.WriteMessage("Initializing " + task.Name + "..."); task.Initialize(context); } foreach (var task in tasks) { logOutput.WriteMessage("Applying " + task.Name + "..."); task.ApplyAll(context); } foreach (var task in tasks) { logOutput.WriteMessage("Finalizing " + task.Name + "..."); task.Finalize(context); } var endTime = DateTime.Now; logOutput.WriteMessage("---------------------------------------------------"); logOutput.WriteMessage("Finished obfuscation process at " + endTime); logOutput.WriteMessage("Duration: " + (endTime - startTime)); }
public void Dispose() { #if !UNITY_WEBGL || UNITY_EDITOR this.isDisposed = true; if (this.newJobEvent != null) { this.newJobEvent.Close(); this.newJobEvent = null; } #endif if (this.Output != null) { this.Output.Dispose(); this.Output = new UnityOutput(); } GC.SuppressFinalize(this); }
public CertificateProcessor(ILogOutput scomms) { if (null == _serverComms) { lock (_locker) { if (null == _serverComms) { _serverComms = scomms; _ipTools = new IPTools() { ServerComms = _serverComms }; _netshWrapper = new NetshWrapper() { ServerComms = _serverComms }; } } } }
public GraphodeCodeAnalyzer(List <IDatabaseAccessDetector> dbAccessDetectors, IDatabaseFinder databaseFinder, IAnalysisEngine analysisEngine = null, ILogOutput logOutput = null) { if (analysisEngine == null) { _analysisEngine = CodeFactory.BuildAnalysisEngine(dbAccessDetectors, databaseFinder); } else { _analysisEngine = analysisEngine; } if (logOutput == null) { _logOutput = CodeFactory.BuildLogOutput(); } else { _logOutput = logOutput; } }
public static void RemoveGlobalOutput(ILogOutput output) { logGame.RemoveOutput(output); logCore.RemoveOutput(output); logEditor.RemoveOutput(output); }
/// <summary> /// Removes a certain output. /// </summary> /// <param name="writer"></param> public void RemoveOutput(ILogOutput writer) { this.strOut.Remove(writer); }
/// <summary> /// Unregisters a registered output. /// </summary> /// <param name="writer"></param> public void UnregisterOutput(ILogOutput writer) { this.strOut.Remove(writer); }
/// <summary> /// Adds an output to write log entries to. /// </summary> /// <param name="writer"></param> public void AddOutput(ILogOutput writer) { this.strOut.Add(writer); }
public Application(IClusterConnection clusterConnection, ILogOutput logger) : base(clusterConnection, logger) { }
public void ToOutput(ILogOutput output) { output.SetContext(_flowStructure.Context); _flowStructure.Output = output; }
public static void ClearLogOutput() { LogOutput = null; }
public ThreadedLogger() { this.Level = UnityEngine.Debug.isDebugBuild ? Loglevels.Warning : Loglevels.Error; this.Output = new UnityOutput(); }
public static void AddGlobalOutput(ILogOutput output) { logGame.AddOutput(output); logCore.AddOutput(output); logEditor.AddOutput(output); }
public static void UnregisterLogOutput(ILogOutput output, string logCategory) { List <ILogOutput> outputs = CategoryOutputs.ContainsKey(logCategory) ? CategoryOutputs[logCategory] : null; outputs?.Remove(output); }
/// <summary> /// Registers an output to write log entries to. /// </summary> /// <param name="writer"></param> public void RegisterOutput(ILogOutput writer) { this.strOut.Add(writer); }
/// <summary> /// Internal to make it accessable to unittests. Don't use this constructor unless you know what you're doing! /// </summary> /// <param name="logOutput"></param> /// <param name="logFormatter"></param> internal Log(ILogOutput logOutput, ILogEntryFormatter logFormatter) { if (logOutput == null || logFormatter == null) throw new ArgumentNullException("Log Output parameter or Formatter parameter is null."); _logOutput = logOutput; _logFormatter = logFormatter; }