예제 #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);
        }