コード例 #1
0
ファイル: Scanner.cs プロジェクト: lanicon/HawkEye
        public async Task <ScanResult> ScanAsync(string filename)
        {
            FileInfo       fileInfo = new FileInfo(filename);
            LoggingSection log      = logging.CreateChild(fileInfo.Name);

            log.Verbose($"Starting {GetType().Name} on {fileInfo.FullName}");
            DateTime  timeStarted = DateTime.Now;
            string    result      = null;
            bool      succeeded;
            Exception exception = null;

            try
            {
                result = await DoScanAsync(fileInfo.FullName, log);

                succeeded = true;
                log.Verbose("Scan was successfull");
            }
            catch (Exception e)
            {
                succeeded = false;
                exception = e;
                log.Warning($"Scan failed: {e.Message}{Environment.NewLine}{e.StackTrace}");
            }
            DateTime timeEnded = DateTime.Now;

            log.Dispose();
            return(new ScanResult(result, fileInfo.FullName, this, timeStarted, timeEnded, succeeded, exception));
        }
コード例 #2
0
        public void Log_ReturnedLogMessage_ShouldHaveLogLevelWarning()
        {
            //Arrange
            LoggingSection loggingSection = new LoggingSection(this);
            LogMessage     logMessage;

            //Act
            logMessage = loggingSection.Warning("Test");

            //Assert
            Assert.NotNull(logMessage);
            Assert.Equal(LogLevel.WARNING, logMessage.LogLevel);
        }