コード例 #1
0
        public void Ctor_DeclareLogObjectWithNullOutput_ExceptionThrown()
        {
            ILogOutput         outLog         = null;
            ILogEntryFormatter entryFormatter = new FileFormatter();

            Assert.Throws <ArgumentNullException>(() => new Log(outLog, entryFormatter));
        }
コード例 #2
0
 static Log()
 {
     prefixedLogs     = new Dictionary <string, ILogOutput>();
     prefixedLogsLock = new object();
     outLock          = new object();
     output           = new LogConsoleOutput();
 }
コード例 #3
0
ファイル: Log.cs プロジェクト: belzecue/ConsoleXT
        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.
                    }
                }
            }
        }
コード例 #4
0
        public static void SetLogOutput(ILogOutput log, LogSeverity minSeverity = LogSeverity.Info)
        {
            Debug.Assert(LogOutput == null);

            LogOutput   = log;
            MinSeverity = minSeverity;
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
ファイル: ImageStore.cs プロジェクト: andersosthus/SfCmd
 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)));
 }
コード例 #7
0
ファイル: Log.cs プロジェクト: raycrasher/duality
 /// <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();
     }
 }
コード例 #8
0
 public AssignmentGraphIndexer(IInstructionParser instructionParser,
                               ITripleStore tripleStore,
                               ILogOutput logOutput)
 {
     _instructionParser = instructionParser;
     _tripleStore       = tripleStore;
     _logOutput         = logOutput;
 }
コード例 #9
0
ファイル: Logs.cs プロジェクト: belzecue/ConsoleXT
 public static void RemoveGlobalOutput(ILogOutput output)
 {
     _globalLogOutput.Remove(output);
     foreach (Log log in All)
     {
         log.RemoveOutput(output);
     }
 }
コード例 #10
0
ファイル: Log.cs プロジェクト: raycrasher/duality
 /// <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();
     }
 }
コード例 #11
0
ファイル: CallTreeWalker.cs プロジェクト: Vanlightly/Graphode
 public CallTreeWalker(IMethodIndexer methodIndexer,
                       IDatabaseResolver databaseResolver,
                       ILogOutput logOutput)
 {
     _methodIndexer    = methodIndexer;
     _databaseResolver = databaseResolver;
     _logOutput        = logOutput;
     _methodNodeLookup = new Dictionary <string, MethodNode>();
 }
コード例 #12
0
ファイル: ConcurrentLog.cs プロジェクト: cinnature/Kuriimu2
        public ConcurrentLogger(ApplicationLevel applicationLevel, ILogOutput output)
        {
            ContractAssertions.IsNotNull(output, nameof(output));

            _output           = output;
            _applicationLevel = applicationLevel;

            _enqueueMessage = false;
        }
コード例 #13
0
ファイル: Log.cs プロジェクト: fennesz/Semesterprojekt4
 /// <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;
 }
コード例 #14
0
ファイル: Log.cs プロジェクト: belzecue/ConsoleXT
 public void PopIndent()
 {
     lock (_outputLock) {
         for (int i = 0; i < _outputs.Count; i++)
         {
             ILogOutput log = _outputs[i];
             try { log.PopIndent(); }
             catch (Exception) {}
         }
     }
 }
コード例 #15
0
 /// <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);
         }
     }
 }
コード例 #16
0
 /// <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);
         }
     }
 }
コード例 #17
0
ファイル: Logs.cs プロジェクト: belzecue/ConsoleXT
        public static void AddGlobalOutput(ILogOutput output)
        {
            if (_globalLogOutput.Contains(output))
            {
                return;
            }

            _globalLogOutput.Add(output);
            foreach (Log log in All)
            {
                log.AddOutput(output);
            }
        }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
        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();
        }
コード例 #20
0
ファイル: AnalysisEngine.cs プロジェクト: Vanlightly/Graphode
 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;
 }
コード例 #21
0
        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));
        }
コード例 #22
0
        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);
        }
コード例 #23
0
 public CertificateProcessor(ILogOutput scomms)
 {
     if (null == _serverComms)
     {
         lock (_locker)
         {
             if (null == _serverComms)
             {
                 _serverComms = scomms;
                 _ipTools     = new IPTools()
                 {
                     ServerComms = _serverComms
                 };
                 _netshWrapper = new NetshWrapper()
                 {
                     ServerComms = _serverComms
                 };
             }
         }
     }
 }
コード例 #24
0
        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;
            }
        }
コード例 #25
0
ファイル: Log.cs プロジェクト: SirePi/duality
 public static void RemoveGlobalOutput(ILogOutput output)
 {
     logGame.RemoveOutput(output);
     logCore.RemoveOutput(output);
     logEditor.RemoveOutput(output);
 }
コード例 #26
0
ファイル: Log.cs プロジェクト: KETMGaming/duality
		/// <summary>
		/// Removes a certain output.
		/// </summary>
		/// <param name="writer"></param>
		public void RemoveOutput(ILogOutput writer)
		{
			this.strOut.Remove(writer);
		}
コード例 #27
0
ファイル: Log.cs プロジェクト: Andrea/duality-withsvn-history
		/// <summary>
		/// Unregisters a registered output.
		/// </summary>
		/// <param name="writer"></param>
		public void UnregisterOutput(ILogOutput writer)
		{
			this.strOut.Remove(writer);
		}
コード例 #28
0
 /// <summary>
 /// Removes a certain output.
 /// </summary>
 /// <param name="writer"></param>
 public void RemoveOutput(ILogOutput writer)
 {
     this.strOut.Remove(writer);
 }
コード例 #29
0
ファイル: Log.cs プロジェクト: KETMGaming/duality
		/// <summary>
		/// Adds an output to write log entries to.
		/// </summary>
		/// <param name="writer"></param>
		public void AddOutput(ILogOutput writer)
		{
			this.strOut.Add(writer);
		}
コード例 #30
0
ファイル: Application.cs プロジェクト: andersosthus/SfCmd
 public Application(IClusterConnection clusterConnection, ILogOutput logger)
     : base(clusterConnection, logger)
 {
 }
コード例 #31
0
 /// <summary>
 /// Adds an output to write log entries to.
 /// </summary>
 /// <param name="writer"></param>
 public void AddOutput(ILogOutput writer)
 {
     this.strOut.Add(writer);
 }
コード例 #32
0
ファイル: LogFlowStructure.cs プロジェクト: fatbwif/LogFlow
 public void ToOutput(ILogOutput output)
 {
     output.SetContext(_flowStructure.Context);
     _flowStructure.Output = output;
 }
コード例 #33
0
 public static void ClearLogOutput()
 {
     LogOutput = null;
 }
コード例 #34
0
 public ThreadedLogger()
 {
     this.Level  = UnityEngine.Debug.isDebugBuild ? Loglevels.Warning : Loglevels.Error;
     this.Output = new UnityOutput();
 }
コード例 #35
0
ファイル: Log.cs プロジェクト: SirePi/duality
 public static void AddGlobalOutput(ILogOutput output)
 {
     logGame.AddOutput(output);
     logCore.AddOutput(output);
     logEditor.AddOutput(output);
 }
コード例 #36
0
        public static void UnregisterLogOutput(ILogOutput output, string logCategory)
        {
            List <ILogOutput> outputs = CategoryOutputs.ContainsKey(logCategory) ? CategoryOutputs[logCategory] : null;

            outputs?.Remove(output);
        }
コード例 #37
0
ファイル: Log.cs プロジェクト: Andrea/duality-withsvn-history
		/// <summary>
		/// Registers an output to write log entries to.
		/// </summary>
		/// <param name="writer"></param>
		public void RegisterOutput(ILogOutput writer)
		{
			this.strOut.Add(writer);
		}
コード例 #38
0
ファイル: Log.cs プロジェクト: JakobVork/Semesterprojekt4
        /// <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;
        }