Exemplo n.º 1
0
Arquivo: Program.cs Projeto: zcmos/CX
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            // Console.ReadKey();

            var log = new NLogAdapter();

            Log.SetCore(log);

            Log.Debug();
        }
Exemplo n.º 2
0
        public void LoggerTest()//logger test
        {
            double[,,] check = new double[10, 10, 10];
            double  time  = 1;
            double  tau   = 0.1;
            double  h     = 1;
            ILogger log   = new NLogAdapter();
            Thermo  teplo = new Thermo(log);

            teplo.PoslCulс3D(check, time, tau, h);
            log = teplo._Logger;
            Assert.AreNotEqual(log, null);
        }
Exemplo n.º 3
0
        public void TestCreateLogEventInfoForOperationStarted()
        {
            var operationStarted = new OperationStarted(
                message: "my message",
                operationName: "operation name",
                tracerName: "tracer name",
                operationKind: OperationKind.Startup,
                operationId: "42",
                severity: Severity.Error);

            var log = NLogAdapter.CreateLogEventInfo(operationStarted);

            log.Properties.All(p => WellKnownProperties.Contains(p.Key.ToString())).Should().BeTrue();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create logger
        /// </summary>
        /// <param name="t">type for which logger will be created</param>
        /// <returns>Concret ILogger implementation</returns>
        public ILogger CreateLogger(Type t)
        {
            if (!_logManagerConfigured)
            {
                this.Configure();
                _logManagerConfigured = true;
            }

            var log    = NLog.LogManager.GetLogger(t.FullName);
            var logger = new NLogAdapter(log);

            //Log
            logger.Log(LogLevel.Debug, "New logger instance initialized");
            return(logger);
        }
Exemplo n.º 5
0
        public OutputDate3D CulcTeploParal3D(InputDate3D inputDate)
        {
            OutputDate3D mass_data = new OutputDate3D();
            ILogger      log       = new NLogAdapter();

            double[,,] array1 = ToMulti3D(inputDate.Mass_u);

            double h     = inputDate.H;
            double time  = inputDate.Time;
            double tau   = inputDate.Tau;
            Teplo  teplo = new Teplo(log);

            double[,,] array2    = teplo.ЗDParalCulc(array1, time, tau, h);
            mass_data.Culc_Teplo = ToJagged3D(array2);
            return(mass_data);
        }
Exemplo n.º 6
0
        public OutputDate CulcTeploParal(InputDate inputDate)
        {
            OutputDate mass_data = new OutputDate();

            double[,] array1 = ToMultiD(inputDate.Mass_u);

            double  h     = inputDate.H;
            double  time  = inputDate.Time;
            double  tau   = inputDate.Tau;
            ILogger log   = new NLogAdapter();
            Thermo  teplo = new Thermo(log);

            double[,] array2     = teplo.ParalCulc(array1, time, tau, h);
            mass_data.Culc_Teplo = ToJagged(array2);
            return(mass_data);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Context.Request.RawUrl))
            {
                var serviceConfig = ServiceConfigurationLoader.Load();
                var logConfig     = new LogConfiguration(serviceConfig.Raw);
                var target        = new NLogAdapter(logConfig);
                var logData       = new LogData();
                logData.LogId   = Guid.NewGuid();
                logData.LogName = "trace";
                logData.User    = HttpContext.Current.User.Identity.Name;
                logData.Message = "Unauthorized: " + Context.Request.RawUrl;

                target.Error(logData);
            }
            this.refresh.Content = "5;URL=" + RedirectUrl;
        }
Exemplo n.º 8
0
        public void TestCreateLogEventInfoForOperationResult()
        {
            var operationResult = new OperationResult(
                message: "my message",
                operationName: "operation name",
                tracerName: "tracer name",
                status: OperationStatus.Failure,
                duration: TimeSpan.FromSeconds(1),
                operationKind: OperationKind.Startup,
                exception: new Exception("Message"),
                operationId: "42",
                severity: Severity.Error);

            var log = NLogAdapter.CreateLogEventInfo(operationResult);

            log.Properties.All(p => WellKnownProperties.Contains(p.Key.ToString())).Should().BeTrue();
        }
Exemplo n.º 9
0
        public void CalculationTest()//calculation test
        {
            int n = 10;

            double[,,] test   = new double[n, n, n];
            double[,,] actual = new double[n, n, n];
            test   = initial();
            actual = initial();
            ILogger log   = new NLogAdapter();
            Thermo  teplo = new Thermo(log);
            double  time  = 1;
            double  tau   = 0.1;
            double  h     = 1;

            teplo.PoslCulс3D(test, time, tau, h);
            Assert.AreNotEqual(test, actual);
        }
Exemplo n.º 10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            var mainLogger = NLog.LogManager.GetLogger("Main");

            try
            {
                var mainLog = new NLogAdapter(mainLogger);
                services.AddSingleton <ILog>(mainLog);

                var checkLogger = NLog.LogManager.GetLogger("CheckLog");
                var checkLog    = new CheckNLogAdapter(checkLogger);
                services.AddSingleton <ICheckLog>(checkLog);

                var xmlFileConfigRepo = new XmlFileConfigRepo(new FileService(), "Faross.config.xml");
                var config            = xmlFileConfigRepo.GetConfiguration();
                services.AddSingleton <IConfigRepo>(xmlFileConfigRepo);

                var timeService = new TimeService();
                services.AddSingleton <ITimeService>(timeService);

                var checkerFactory = new CheckerFactory(timeService);
                var checkStats     = new InMemoryCheckStats();
                var scheduler      = new ThreadedCheckScheduler(checkLog, checkStats, checkerFactory, mainLog);
                services.AddSingleton <ICheckScheduler>(scheduler);
                services.AddSingleton <ICheckStats>(checkStats);

                scheduler.Init(config);
            }
            catch (Exception ex)
            {
                mainLogger.Fatal(ex.ToString());
            }
        }
 protected NLogRegistrationBase(NLogAdapter nLogAdapter)
 {
     _nLogAdapter = nLogAdapter;
 }