Exemplo n.º 1
0
        public void CompositeLogConstructorTest2()
        {
            ILog[]       logs   = null; // TODO: Initialize to an appropriate value
            CompositeLog target = new CompositeLog(logs);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var configuration = new ContainerConfiguration(typeof(CassandraFileSystem).Assembly);
            var container     = new Container(configuration);

            var settings = new FileLogSettings();
            var logger   = new CompositeLog(new ConsoleLog(), new FileLog(settings));

            container.Configurator.ForAbstraction <ILog>().UseInstances(logger);

            var config = JsonConvert.DeserializeObject <Config>(File.ReadAllText("config.json"));

            if (!config.DefaultTTL.HasValue || config.DefaultTTL.Value == 0)
            {
                config.DefaultTTL = new TimeSpan(14, 0, 0, 0).Seconds;
            }
            config.DefaultDataBufferSize ??= 4194304;
            container.Configurator.ForAbstraction <Config>().UseInstances(config);

            CassandraConfigurator.ConfigureCassandra(container, logger);

            logger.Info("Creating filesystem...");

            var constructor = container.GetCreationFunc <string[], CassandraFileSystem>();

            using var fs = constructor(args);
            logger.Info("Starting filesystem");
            fs.Start();
        }
Exemplo n.º 3
0
        public void CompositeLogConstructorTest1()
        {
            string       name   = string.Empty; // TODO: Initialize to an appropriate value
            CompositeLog target = new CompositeLog(name);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Exemplo n.º 4
0
        public void WriteTest()
        {
            CompositeLog target = new CompositeLog(); // TODO: Initialize to an appropriate value
            LogItem      item   = null;               // TODO: Initialize to an appropriate value

            target.Write(item);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Exemplo n.º 5
0
        public static CompositeLog mapComposite(Log log)
        {
            CompositeLog cmpLog = new CompositeLog();

            cmpLog.machine   = log.machine;
            cmpLog.machineIP = log.machineIP;
            cmpLog.logDate   = log.logDate;
            cmpLog.user      = log.user;
            return(cmpLog);
        }
Exemplo n.º 6
0
        public static void Init()
        {
            var totalFileLog = CreateFileLog("TotalLog")
                               .WithMinimumLevel(LogLevel.Info)
                               .WithMinimumLevelForSourceContexts(LogLevel.Warn, "HandlerTask", "CassandraDistributedTaskQueue")
                               .WithMinimumLevelForSourceContext("HandlerManager", LogLevel.Warn);

            var errorFileLog = CreateFileLog("ErrorLog")
                               .WithMinimumLevel(LogLevel.Error);

            var consoleLog = new ConsoleLog().WithMinimumLevel(LogLevel.Info);
            var defaultLog = new CompositeLog(totalFileLog, errorFileLog, consoleLog).WithThreadName();

            LogProvider.Configure(defaultLog, canOverwrite: true);
        }
        private static ILog SetUpLogging()
        {
            LoggingConfigurationHelpers.SetupUnhandledExceptionLogging();

            defaultLog = new CompositeLog(CreateConsoleLog(), CreateFileLog())
                         .WithThreadName()
                         .WithMinimumLevel(LogLevel.Info)
                         .WithMinimumLevelForSourceContext("CassandraThriftClient", LogLevel.Warn)
                         .WithMinimumLevelForSourceContexts(LogLevel.Warn, "CassandraDistributedTaskQueue", "HandlerTask")
                         .WithMinimumLevelForSourceContexts(LogLevel.Warn, "CassandraDistributedTaskQueue", "HandlerManager");

            LogProvider.Configure(defaultLog, canOverwrite: false);

            return(defaultLog);
        }
Exemplo n.º 8
0
 public static void sendLog(CompositeLog lg)
 {
     ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
     try {
         logger.Debug("Trying to connect with WCF service.");
         client.Open();
         client.sendLog(lg);
         logger.Trace("Log sended with success");
         client.Close();
         logger.Trace("WCF connection closed");
     } catch (Exception ex) {
         logger.Error("Error: " + ex.ToString());
         client.Abort(); //delete everything in the connection
     }
 }
Exemplo n.º 9
0
        public void TestSetup()
        {
            log1 = Substitute.For <ILog>();
            log2 = Substitute.For <ILog>();
            log3 = Substitute.For <ILog>();

            log1.IsEnabledFor(Arg.Any <LogLevel>()).Returns(true);
            log2.IsEnabledFor(Arg.Any <LogLevel>()).Returns(true);
            log3.IsEnabledFor(Arg.Any <LogLevel>()).Returns(true);

            log1.ForContext(Arg.Any <string>()).Returns(log1);
            log2.ForContext(Arg.Any <string>()).Returns(log2);
            log3.ForContext(Arg.Any <string>()).Returns(log3);

            compositeLog = new CompositeLog(log1, log2, log3);
        }
        public void OneTimeSetup()
        {
            var configuration = new ContainerConfiguration(typeof(CassandraFileSystem).Assembly);
            var container     = new Container(configuration);
            var settings      = new FileLogSettings();
            var logger        = new CompositeLog(new ConsoleLog(), new FileLog(settings));

            container.Configurator.ForAbstraction <ILog>().UseInstances(logger);
            container.Configurator.ForAbstraction <Config>().UseInstances(Config);
            CassandraConfigurator.ConfigureCassandra(container, logger);
            directoryRepository = container.Get <DirectoryRepository>();
            fileRepository      = container.Get <FileRepository>();
            var session = container.Get <ISession>();

            directoriesTableEvent = new Table <CQLDirectory>(session);
            filesTableEvent       = new Table <CQLFile>(session);
        }
Exemplo n.º 11
0
        private static void InitializeLogging(bool console)
        {
            WinEventLog eventLog;

            try
            {
                eventLog = new WinEventLog("CMSSync");
                eventLog.LogInfo("Initializing CMSSync Service");
            }
            catch (Exception e)
            {
                throw new ServiceStartupException("Service cannot be started because it cannot write to event log: {0} - {1}".Fmt(e.GetType().Name, e.Message));
            }

            bool logVerbose = config.LogVerbose;

#if DEBUG
            logVerbose = true;
#endif
            if (!logVerbose && !console)
            {
                log = eventLog;
            }
            else
            {
                var clog = new CompositeLog();
                if (console)
                {
                    clog.AddLog(new ConsoleLog());
                }
                if (logVerbose)
                {
                    clog.AddLog(new FileLog(new FileInfo(Path.Combine(HomeFolder, "log.txt"))));
                }
                clog.AddLog(eventLog);
                log = clog;
            }

            log.LogDebug("");
            log.LogDebug(DateTime.Now + " Starting service in folder " + HomeFolder);
        }
Exemplo n.º 12
0
        public MainWindowViewModel()
        {
            this.People = new ObservableCollection <Person>();
            var documents                 = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var dataTransferPath          = System.IO.Path.Combine(documents, "FundManager");
            var dataTransferDirectoryInfo = new DirectoryInfo(dataTransferPath);
            var log = new CompositeLog(LoggerNames.DbLoggerName);

            this.personStore = new PersonStore(dataTransferDirectoryInfo, log);

            var peopleResult = this.personStore.GetAll();

            if (peopleResult.IsOk)
            {
                peopleResult.ResultValue
                .ToList()
                .ForEach(x => this.People.Add(x));

                this.SelectedPerson = peopleResult.ResultValue.Head;
            }
        }
Exemplo n.º 13
0
 private void CreateCompositeLogger()
 {
     _compositeLog = new CompositeLog(_application, _container.ComponentRegistry);
 }
Exemplo n.º 14
0
        public void IsEnabledFor_should_return_false_when_there_are_no_underlying_logs()
        {
            compositeLog = new CompositeLog();

            compositeLog.IsEnabledFor(LogLevel.Info).Should().BeFalse();
        }
Exemplo n.º 15
0
        public void CompositeLogConstructorTest()
        {
            CompositeLog target = new CompositeLog();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }