private static void registerLogging(IContainer container)
        {
            var loggerCreator = new LoggerCreator();

            container.RegisterImplementationOf((ILoggerCreator)loggerCreator);
            container.Register <IOSPSuiteLogger, OSPSuiteLogger>(LifeStyle.Singleton);
        }
Beispiel #2
0
        protected BaseForm(InputParams settings         = null,
                           bool addDefaultConsoleLogger = true,
                           params Logger[] loggersCollection)
        {
            if (settings != null)
            {
                this.settings = settings;
            }
            browserClosedTougle = !this.settings.Browser.IsOpened;
            logedBrowserClosed  = browserClosedTougle;

            Handle = this.settings.Browser.Window.Handle;

            this.settings.Browser.WindowChanged += WindowChanged;
            this.settings.Browser.BrowserClosed += BrowserClosed;
            this.settings.Browser.WindowClosed  += WindowClosed;

            if (loggersCollection != null && loggersCollection.Length > 0)
            {
                loggers.Add(loggersCollection);
            }
            if (addDefaultConsoleLogger)
            {
                loggers.Add(LoggerCreator.GetLogger(LoggerTypes.ConsoleLogger, null));
            }

            Log(SeleniumWrapper.Logging.LogType.Info, $"Opened page \"{this.settings.Browser.Window.Url}\"", null);
        }
Beispiel #3
0
 public DownloadSteam(IBrowser browser, Link link, string pathToDownload, TimeSpan timeout, string logFilePath, string url) :
     base(null, true, LoggerCreator.GetLogger(LoggerTypes.FileLogger, null, logFilePath))
 {
     link.Click();
     this.pathToDownload = pathToDownload;
     this.timeout        = timeout;
 }
Beispiel #4
0
 public WhenDispatching()
 {
     _serviceProvider.Setup(p => p.GetService(typeof(IEnumerable <IMessageHandler <IMessage> >)))
     .Returns(new[] { _handler.Object }.TakeWhile(_ => true));
     _logger = New.Common().Logger <EventDispatcher>();
     _sut    = new EventDispatcher(_serviceProvider.Object, _logger.Creation);
 }
Beispiel #5
0
 public WhenDispatchingStrongTypedQuery()
 {
     _query = new TestQuery();
     _serviceProvider.Setup(p => p.GetService(typeof(IQueryHandler <TestQuery, string>)))
     .Returns(_handler.Object);
     _logger = New.Common().Logger <QueryDispatcher>();
     _sut    = new QueryDispatcher(_serviceProvider.Object, _logger.Creation);
 }
Beispiel #6
0
 public WhenDispatchingGenericQuery()
 {
     _query = It.IsAny <IQuery <string> >();
     _serviceProvider.Setup(p => p.GetService(typeof(IQueryHandler <IQuery <string>, string>)))
     .Returns(_handler.Object);
     _logger = New.Common().Logger <QueryDispatcher>();
     _sut    = new QueryDispatcher(_serviceProvider.Object, _logger.Creation);
 }
Beispiel #7
0
        public DafnyLanguageServer(string[] args)
        {
            var configInitializer = new ConfigInitializer(args);

            configInitializer.SetUp();
            configInitErrors = configInitializer.Errors;
            log = LoggerCreator.GetLogger();
        }
Beispiel #8
0
 public WhenDispatching()
 {
     _serviceProvider.Setup(p => p.GetService(typeof(IMessageHandler <IMessage>)))
     .Returns(_handler.Object);
     _serviceProvider.Setup(p => p.GetService(typeof(ICommandBehaviorPipeline <IMessage>)))
     .Returns(_pipeline.Object);
     _logger = New.Common().Logger <CommandDispatcher>();
     _sut    = new CommandDispatcher(_serviceProvider.Object, _logger.Creation);
 }
Beispiel #9
0
            public void ClientCode(LoggerCreator creator)
            {
                creator.IsActive = true;
                creator.Info("MessageA");
                creator.Info("MessageB");

                creator.IsActive = false;
                creator.Info("MessageC");
            }
Beispiel #10
0
        static void Main()
        {
            ILogger logger = LoggerCreator.CreateLogger(a => a.AddConsole());

            logger.Info("test");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1(logger));
        }
        public MainPage(MainPageSettings settings) : base(null, true, LoggerCreator.GetLogger(LoggerTypes.FileLogger, null, settings.PathToLogFile))
        {
            pageSettings = settings;

            if (!string.IsNullOrEmpty(settings.PathToLogFile) && !string.IsNullOrWhiteSpace(settings.PathToLogFile))
            {
                loggers.Add();
            }

            ChangeLanguage();
        }
Beispiel #12
0
        public void FileLogger_FileExistAtPath_True()
        {
            // Arrange
            string fileName = "logFile.txt";
            var    logger   = LoggerCreator.CreateLogger(a => a.AddFileLog(fileName, LogDirectory, Configuration.LogEvent.Info));

            // Act
            logger.Info("Testing.");

            // Assert
            Assert.IsTrue(File.Exists(Path.Combine(LogDirectory, fileName)));
        }
        public GamesPage(IBrowser browser, AgeVerificationData verificationData, TimeSpan timeout, Language ln, string gameType, string pathToLogFile) :
            base(null, true, LoggerCreator.GetLogger(LoggerTypes.FileLogger, null, pathToLogFile))
        {
            this.verificationData = verificationData;
            this.timeout          = timeout;
            this.language         = ln;
            this.pathToLogFile    = pathToLogFile;
            this.gameType         = gameType;

            var elem = settings.Browser.Window.FindElement <Text>(By.XPath(headderLocator)).WaitForExists <Text>(timeout);

            Headder = elem.InnerHTML;
        }
Beispiel #14
0
        public void FileLogger_FileContainsSpecifiedText_True()
        {
            // Arrange
            string message = "Testing.";

            string fileName = "logFile.txt";
            var    logger   = LoggerCreator.CreateLogger(a => a.AddFileLog(fileName, LogDirectory, Configuration.LogEvent.Info));

            // Act
            logger.Info(message);

            // Assert
            string text = File.ReadAllText(Path.Combine(LogDirectory, fileName));

            Assert.IsTrue(text.Contains(message));
        }
Beispiel #15
0
        public void FileLogger_InfoLogFileSpecifiedButDebugEventCalled_Throw()
        {
            // Arrange
            string debugMessage = "DebugMessage.";

            string fileName = "logFile.txt";
            var    logger   = LoggerCreator.CreateLogger(a => a.AddFileLog(fileName, LogDirectory, Configuration.LogEvent.Info));

            // Act
            logger.Info("Testing.");
            logger.Debug(debugMessage);

            // Assert
            string text = File.ReadAllText(Path.Combine(LogDirectory, fileName));

            Assert.IsFalse(text.Contains(debugMessage));
        }
Beispiel #16
0
        public static void Main(string[] args)
        {
            Log.Logger = LoggerCreator.CreateLoggerConfiguration();

            try
            {
                Log.Information("Starting web host");
                BuildWebHost(args).Run();
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "Host terminated unexpectedly");
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }
Beispiel #17
0
        public void FileLogger_SpecifiedFileForInfoLoggerAndFileForOtherEvents_OtherFileExist()
        {
            // Arrange
            string infoMessage  = "InfoMessage.";
            string debugMessage = "DebugMessage.";

            string infoFileName  = "infoLogFile.txt";
            string otherFileName = "otherLogFile.txt";

            var logger = LoggerCreator.CreateLogger(a => a.AddFileLog(infoFileName, LogDirectory, Configuration.LogEvent.Info)
                                                    .AddFileLog(otherFileName, LogDirectory, Configuration.LogEvent.AllOther));

            // Act
            logger.Info(infoMessage);
            logger.Debug(debugMessage);

            // Assert
            Assert.IsTrue(File.Exists(Path.Combine(LogDirectory, otherFileName)));
        }
        internal FileProcessor(string inFile, string outLocation)
        {
            var inputIsCsv = Path.GetExtension(inFile).ToLower() == ".csv";
            var outFileWithoutExtension = outLocation + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(inFile);
            var config = new OrchestratorConfig(LoggerCreator.CreateLogger(LoggerType.LogFile, "Unbound JSON translation to/from CSV.", LogEntrySeverity.Information))
            {
                ReportProgress         = true,
                ProgressInterval       = 1000,
                ProgressChangedHandler = (s, e) => { if (e.Phase == Phase.Intake)
                                                     {
                                                         Console.Write($"\rProcessed {e.RecCnt:N0} records so far...");
                                                     }
                },
                PhaseFinishedHandler = (s, e) => { if (e.Phase == Phase.Intake)
                                                   {
                                                       Console.WriteLine($"\rProcessed {e.RecCnt:N0} records. Done!   ");
                                                   }
                },
                InputFileName = inFile
            };

            if (inputIsCsv) // CSV to UnboundJSON
            {
                config.InputDataKind               = KindOfTextData.Delimited;
                config.HeadersInFirstInputRow      = true;
                config.AllowTransformToAlterFields = true;
                config.OutputDataKind              = KindOfTextData.UnboundJSON;
                config.XmlJsonOutputSettings       = "IndentChars|  "; // pretty print
                config.OutputFileName              = outFileWithoutExtension + ".json";
            }
            else // UnboundJSON to CSV
            {
                config.InputDataKind               = KindOfTextData.UnboundJSON;
                config.AllowOnTheFlyInputFields    = true; // TODO: consider UnboundJSON ignoring this setting like X12
                config.AllowTransformToAlterFields = true; //IMPORTANT! otherwise null items will be produced!
                config.OutputDataKind              = KindOfTextData.Delimited;
                config.OutputFileName              = outFileWithoutExtension + ".csv";
                config.HeadersInFirstOutputRow     = true;
            }

            Orchestrator = OrchestratorCreator.GetEtlOrchestrator(config);
        }
Beispiel #19
0
        public void FileLogger_SpecifiedFileForInfoLoggerAndFileForOtherEvents_InfoFileContainsInfoMessage()
        {
            // Arrange
            string infoMessage  = "InfoMessage.";
            string debugMessage = "DebugMessage.";

            string infoFileName  = "infoLogFile.txt";
            string otherFileName = "otherLogFile.txt";

            var logger = LoggerCreator.CreateLogger(a => a.AddFileLog(infoFileName, LogDirectory, Configuration.LogEvent.Info)
                                                    .AddFileLog(otherFileName, LogDirectory, Configuration.LogEvent.AllOther));

            // Act
            logger.Info(infoMessage);
            logger.Debug(debugMessage);

            // Assert
            string text = File.ReadAllText(Path.Combine(LogDirectory, infoFileName));

            Assert.IsTrue(text.Contains(infoMessage));
        }
Beispiel #20
0
        public void Setup()
        {
            if (File.Exists(fileWithSettings))
            {
                config = Config.Deserialization();
            }
            else
            {
                config = new Config();
                config.Serialization();
            }

            LocalisationKeeper.Configure(config.PathToLocalisationForTest_1, config.PathToLocalisationForTest_2,
                                         config.PathToMonthLocalisation, config.PathToLanguageNames);

            loggers.Add(new [] { LoggerCreator.GetLogger(LoggerTypes.ConsoleLogger, null),
                                 LoggerCreator.GetLogger(LoggerTypes.FileLogger, null, config.LogFileName) });

            browser            = BrowserCreator.GetConfiguredBrowser(config.browser);
            browser.Window.Url = config.MainUrl;
            browser.Window.Maximize();
            browser.Window.Scroll(0, 0);

            homePage = new MainPage(new MainPageSettings
            {
                Language         = config.Language,
                PathToDownload   = config.PathToDownload,
                PathToLogFile    = config.LogFileName,
                Timeout          = TimeSpan.FromSeconds(config.TimeautSeconds),
                DownloadUrl      = config.DownloadUrl,
                verificationData = new AgeVerificationData
                {
                    Day   = config.Day,
                    Month = config.Month,
                    Year  = config.Year
                }
            });
        }
        public SelectedGamePage(TimeSpan timeout, AgeVerificationData verificationData, Language ln, string gameName, string pathToLogFile) :
            base(null, true, LoggerCreator.GetLogger(LoggerTypes.FileLogger, null, pathToLogFile))
        {
            AgeVerificationPage verificationPage = new AgeVerificationPage(pathToLogFile);

            if (verificationPage.IsPageOpened)
            {
                verificationPage.Day.SelectByValue(verificationData.Day.ToString());
                verificationPage.Month.SelectByValue(LocalisationKeeper.Get(verificationData.Month, ln));
                verificationPage.Year.SelectByValue(verificationData.Year.ToString());
                verificationPage.Submit();
            }
            this.gameName = gameName;

            BrowserWait.Wait(timeout, (IBrowser b) =>
            {
                return(b.Window.FindElement <Contaner>(By.XPath(programNameLocator)).InnerHTML == gameName);
            }, null, typeof(NoSuchElementException));

            Name          = gameName;
            this.timeout  = timeout;
            this.language = ln;
        }
        public void Ctor_SomeExplicitSettings_SettingsAccepted()
        {
            //arrange
            var config = new OrchestratorConfig(LoggerCreator.CreateLogger(LoggerType.LogFile, "Test", LogEntrySeverity.Error));

            //act
            // note that this is not a sensible set of settings (!)
            config.ExplicitTypeDefinitions = "DOB|D,Amount|M,Name|S";
            config.TypeDefiner             = fn => new ItemDef(ItemType.Int, "000"); //everything int, except for 3 exceptions above
            config.MarkerStartsCluster     = false;
            config.BufferSize             = 7;
            config.InputDataKind          = KindOfTextData.Arbitrary;
            config.AsyncIntake            = true;
            config.RetainQuotes           = true;
            config.ActionOnDuplicateKey   = ActionOnDuplicateKey.AssignDefaultKey;
            config.DefaultInputFieldWidth = 6;
            config.TransformerType        = TransformerType.ClusterFilter;
            config.ClusterFilterPredicate = c => false;
            config.RecordFilterPredicate  = r => false; //makes no sense in the orchestrator, but good to test
            config.ConcurrencyLevel       = 19;
            config.OutputDataKind         = KindOfTextData.Flat;
            config.OutputFileNames        = "blahblah";
            config.QuotationMode          = QuotationMode.StringsAndDates;
            config.TrimOutputValues       = true;
            config.OutputKeyPrefix        = "pfx_";

            //assert
            //Logger:
            config.Logger.LoggerType.Should().Be(LoggerType.LogFile);
            config.Logger.LoggingThreshold.Should().Be(LogEntrySeverity.Error);
            // Environmental settings:
            config.ConfigName.Should().BeNull();
            config.DataConveyerInfo.Should().BeOfType(typeof(ProductInfo));
            config.DataConveyerInfo.Name.Should().Be("DataConveyer");
            var ver = Assembly.GetAssembly(typeof(EtlOrchestrator)).GetName().Version;

            config.DataConveyerInfo.Version.Should().Be($"{ver.Major}.{ver.Minor}");
            //General settings:
            config.ExplicitTypeDefinitions.Should().Be("DOB|D,Amount|M,Name|S");
            config.TypeDefiner.Should().BeOfType(typeof(Func <string, ItemDef>));
            config.TypeDefiner.Should().NotBe(OrchestratorConfig.DefaultTypeDefiner);
            config.TypeDefiner("anyKey").Type.Should().Be(ItemType.Int);
            config.EagerInitialization.Should().BeFalse();
            config.BufferSize.Should().Be(7);
            config.ReportProgress.Should().BeFalse();
            config.ProgressInterval.Should().Be(0);
            config.PhaseStartingHandler.Should().BeNull();
            config.ProgressChangedHandler.Should().BeNull();
            config.PhaseFinishedHandler.Should().BeNull();
            //Intake specific settings:
            config.InputDataKind.Should().Be(KindOfTextData.Arbitrary);
            config.InputFileNames.Should().BeNull();
            config.AsyncIntake.Should().BeTrue();
            config.IntakeSupplier.Should().Be(OrchestratorConfig.DefaultIntakeSupplier);
            config.AsyncIntakeSupplier.Should().Be(OrchestratorConfig.DefaultAsyncIntakeSupplier);
            config.IntakeBufferFactor.Should().Be(1.5);
            config.HeadersInFirstInputRow.Should().BeFalse();
            config.RetainQuotes.Should().BeTrue();
            config.TrimInputValues.Should().BeFalse();
            config.InputKeyPrefix.Should().BeNull();
            config.ExcludeItemsMissingPrefix.Should().BeFalse();
            config.ActionOnDuplicateKey.Should().Be(ActionOnDuplicateKey.AssignDefaultKey);
            config.ClusterMarker.Should().Be(OrchestratorConfig.DefaultClusterMarker);
            config.MarkerStartsCluster.Should().BeFalse();
            config.InputFields.Should().BeNull();
            config.ArbitraryInputDefs.Should().BeNull();
            config.DefaultInputFieldWidth.Should().Be(6);
            config.AllowOnTheFlyInputFields.Should().BeFalse();
            //Transformer specific settings:
            config.TransformerType.Should().Be(TransformerType.ClusterFilter);
            config.ClusterboundTransformer.Should().Be(OrchestratorConfig.DefaultClusterboundTransformer);
            config.RecordboundTransformer.Should().Be(OrchestratorConfig.DefaultRecordboundTransformer);
            config.ClusterFilterPredicate.Should().BeOfType(typeof(Func <ICluster, bool>));
            config.ClusterFilterPredicate.Should().NotBe(OrchestratorConfig.DefaultClusterFilterPredicate);
            config.ClusterFilterPredicate(null).Should().BeFalse();
            config.RecordFilterPredicate.Should().NotBe(OrchestratorConfig.DefaultRecordFilterPredicate);
            config.RecordFilterPredicate(null).Should().BeFalse(); // this predicate would never be called (due to TransformerType setting)
            config.UniversalTransformer.Should().Be(OrchestratorConfig.DefaultUniversalTransformer);
            config.ConcurrencyLevel.Should().Be(19);
            config.TransformBufferFactor.Should().Be(1);
            config.AllowTransformToAlterFields.Should().BeFalse();
            //Output specific settings:
            config.OutputDataKind.Should().Be(KindOfTextData.Flat);
            config.OutputFileNames.Should().Be("blahblah");
            config.AsyncOutput.Should().BeFalse();
            config.OutputConsumer.Should().Be(OrchestratorConfig.DefaultOutputConsumer);
            config.AsyncOutputConsumer.Should().Be(OrchestratorConfig.DefaultAsyncOutputConsumer);
            config.OutputBufferFactor.Should().Be(1.5);
            config.HeadersInFirstOutputRow.Should().BeFalse();
            config.QuotationMode.Should().Be(QuotationMode.StringsAndDates);
            config.TrimOutputValues.Should().BeTrue();
            config.OutputKeyPrefix.Should().Be("pfx_");
            config.OutputFields.Should().BeNull();
            config.ArbitraryOutputDefs.Should().BeNull();
            config.DefaultOutputFieldWidth.Should().Be(10);
            config.LeaderContents.Should().BeNull();
            config.TrailerContents.Should().BeNull();
            config.ExcludeExtraneousFields.Should().BeFalse();
        }
 public AgeVerificationPage(string pathToLogFile) :
     base(null, true, LoggerCreator.GetLogger(LoggerTypes.FileLogger, null, pathToLogFile))
 {
 }
Beispiel #24
0
 public Loggable()
 {
     Logger = LoggerCreator.Create(GetType());
 }
 public ThesisController(IThesesSystemData data, LoggerCreator loggerCreater, IStorage storage)
     : base(data)
 {
     this.loggerCreator = loggerCreater;
     this.storage       = storage;
 }
 public IdeaController(IThesesSystemData data, LoggerCreator loggerCreator)
     : base(data)
 {
     this.loggerCreator = loggerCreator;
 }