GetCurrentClassLogger() private method

private GetCurrentClassLogger ( ) : Logger
return Logger
Ejemplo n.º 1
0
        public static ABIExitCode Compile(ABIFileSystemOptions options, LogFactory factory)
        {
            #region Argument exceptions

            if (options == null)
                throw new ArgumentNullException("options");

            if (factory == null)
                throw new ArgumentNullException("factory");

            #endregion

            _logger = factory.GetCurrentClassLogger();
            _logger.Debug(options);
            try
            {
                if (!Validate(options))
                    return ABIExitCode.ErrorDuringValidation;

                var engine = new CompilerEngine(options, factory);

                var result = engine.Compile();
                Debug.Assert(result != ABIExitCode.ErrorExitCodeUnassigned);
                return result;
            }
            catch (Exception ex) // avoid external unhandled exceptions
            {
                _logger.Error(ex);
            }

            return ABIExitCode.ErrorUnhandledException;
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            var loggerFactory = new NLOG.LogFactory();

            if (_NLogConfiguration != null)
            {
                loggerFactory = NLOG.Web.NLogBuilder.ConfigureNLog(_NLogConfiguration);
            }
            else
            {
                loggerFactory = NLOG.Web.NLogBuilder.ConfigureNLog(_NLogConfigFile);
            }

            var logger = loggerFactory.GetCurrentClassLogger();

            var host = Core.Program.WebHostBuilder(args, typeof(Program).Assembly)
                       .UseStartup(_startupConfigurationType)
                       .UseNLog()
                       .Build();

            try
            {
                host.Run();
            }
            catch (Exception ex)
            {
                logger.Fatal(ex, "Stopped program");
                throw;
            }
            finally
            {
                NLOG.LogManager.Shutdown();
            }
        }
Ejemplo n.º 3
0
        public void TypedGetCurrentClassLoggerTest()
        {
            LogFactory lf = new LogFactory();

            MyLogger l1 = (MyLogger)lf.GetCurrentClassLogger(typeof(MyLogger));
            MyLogger l2 = (MyLogger)lf.GetCurrentClassLogger(typeof(MyLogger));
            Logger l3 = lf.GetCurrentClassLogger(typeof(Logger));
            Logger l4 = lf.GetCurrentClassLogger(typeof(Logger));
            Logger l5 = lf.GetCurrentClassLogger();
            Logger l6 = lf.GetCurrentClassLogger();

            Assert.AreSame(l1, l2);
            Assert.AreSame(l3, l4);
            Assert.AreSame(l5, l6);
            Assert.AreSame(l3, l5);

            Assert.AreNotSame(l1, l3);

            Assert.AreEqual("NLog.UnitTests.GetLoggerTests", l1.Name);
            Assert.AreEqual("NLog.UnitTests.GetLoggerTests", l3.Name);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            ContainerBuilder builder = new ContainerBuilder();
            builder.RegisterType<CommandRunner>().As<ICommandRunner>();
            builder.RegisterType<QueryParser>().As<IQueryParser>();
            builder.RegisterType<QueryValidator>().As<IQueryValidator>();
            builder.RegisterType<DirectoryInfoProcessor>().As<IDirectoryInfoProcessor>();

            LogFactory logFactory = new LogFactory();
            Logger logger = logFactory.GetCurrentClassLogger();

            IContainer diContainer = builder.Build();
            using (var scope = diContainer.BeginLifetimeScope())
            {
                ICommandRunner commandRunner = scope.Resolve<ICommandRunner>();
                IQueryValidator queryValidator = scope.Resolve<IQueryValidator>();
                IQueryParser queryParser = scope
                    .Resolve<IQueryParser>(new TypedParameter(typeof(IQueryValidator),
                        queryValidator));
                QueryProcessor queryProcessor = new QueryProcessor(commandRunner,
                    queryParser);

                OperationResult queryRunningResult = queryProcessor.RunQuery(args);
                Console.WriteLine(queryRunningResult.Successful);

                if (!queryRunningResult.Successful)
                {
                    string logString = String.Format("\"{0}\". {1}",
                        String.Join(" ", args),
                        queryRunningResult.Description);

                    logger.Info(logString);
                }
            #if DEBUG
                Console.ReadLine();
            #endif
            }
        }
Ejemplo n.º 5
0
 public void Initialize(LogFactory log)
 {
     _logger = log.GetCurrentClassLogger();
     _logger.Debug("Initialize");
 }
Ejemplo n.º 6
0
 public CompilerEngine(ABIFileSystemOptions options, LogFactory factory)
 {
     _logger = factory.GetCurrentClassLogger();
     _options = options;
 }
Ejemplo n.º 7
0
        public void GenericGetCurrentClassLoggerTest()
        {
            LogFactory<MyLogger> lf = new LogFactory<MyLogger>();

            MyLogger l1 = lf.GetCurrentClassLogger();
            MyLogger l2 = lf.GetCurrentClassLogger();

            Assert.AreSame(l1, l2);
            Assert.AreEqual("NLog.UnitTests.GetLoggerTests", l1.Name);
        }