static FileLoggingBenchmark()
 {
     serilogLogger = CreateSerilogLogger();
     nlogLogger    = CreateNLogLogger();
     log4NetLogger = CreateLog4NetLogger();
     streamWriter  = CreateStreamWriter();
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json", true, true)
                                    .Build();

            // NLog: setup the logger first to catch all errors
            NLog.LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration("nlog.config");
            NLog.ILogger logger            = NLog.LogManager.Configuration.LogFactory.GetLogger("");
            var          from_mqtt_address = config.GetSection("MQTTBrokers:From").Get <MqttAddress>();
            var          to_mqtt_address   = config.GetSection("MQTTBrokers:To").Get <MqttAddress>();
            var          topic             = config.GetSection("SubscribeTopic").Get <string>();

            cancellationTokenSource = new CancellationTokenSource();
            mqtt_worker             = new SubscribeWorker(logger, topic, to_mqtt_address);
            Console.CancelKeyPress += Console_CancelKeyPress;
            Task t = mqtt_worker.ConnectionAsync(from_mqtt_address.ClientId, from_mqtt_address.BindAddress, from_mqtt_address.Port, from_mqtt_address.QosLevel, topic);

            t.Wait();
            var token = cancellationTokenSource.Token;

            while (token.IsCancellationRequested == false)
            {
                Thread.Sleep(100);
            }
            Console.WriteLine("Complete");
        }
        public void AttachToLogger(NLog.ILogger logger)
        {
            // When the NPM task emits complete lines, pass them through to the real logger
            StdOut.OnReceivedLine += line =>
            {
                if (!string.IsNullOrWhiteSpace(line))
                {
                    // NPM tasks commonly emit ANSI colors, but it wouldn't make sense to forward
                    // those to loggers (because a logger isn't necessarily any kind of terminal)
                    //logger.LogInformation(StripAnsiColors(line));
                    logger.Info(StripAnsiColors(line));
                }
            };

            StdErr.OnReceivedLine += line =>
            {
                if (!string.IsNullOrWhiteSpace(line))
                {
                    //logger.LogError(StripAnsiColors(line));
                    logger.Error(StripAnsiColors(line));
                }
            };

            // But when it emits incomplete lines, assume this is progress information and
            // hence just pass it through to StdOut regardless of logger config.
            StdErr.OnReceivedChunk += chunk =>
            {
                var containsNewline = Array.IndexOf(
                    chunk.Array, '\n', chunk.Offset, chunk.Count) >= 0;
                if (!containsNewline)
                {
                    Console.Write(chunk.Array, chunk.Offset, chunk.Count);
                }
            };
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json", true, true)
                                    .Build();

            // NLog: setup the logger first to catch all errors
            NLog.LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration("nlog.config");
            NLog.ILogger           logger            = NLog.LogManager.Configuration.LogFactory.GetLogger("");
            CassandraConfiguration cassandra_config  = config.GetSection("cassandra").Get <CassandraConfiguration>();
            MqttAddress            data_mqtt_address = config.GetSection("MQTTBrokers:DataBrokerAddress").Get <MqttAddress>();

            cancellationTokenSource = new CancellationTokenSource();
            IBackgroundTaskQueue <JObject> dataQueue = new BackgroundTaskQueue <JObject>();

            mqtt_worker                         = new CollectWorker(dataQueue);
            Console.CancelKeyPress             += Console_CancelKeyPress;
            cassandraWorker                     = new BackgroundCassandraWorker(logger, cancellationTokenSource, cassandra_config, dataQueue);
            cassandraWorker.RunWorkerCompleted += CassandraWorker_RunWorkerCompleted;

            Task t = mqtt_worker.ConnectionAsync(data_mqtt_address.ClientId, data_mqtt_address.BindAddress, data_mqtt_address.Port, (ushort)data_mqtt_address.QosLevel, data_mqtt_address.Topic);

            t.Wait();
            Task worker_Task = cassandraWorker.RunWorkerAsync();

            worker_Task.Wait();
        }
Beispiel #5
0
        private static void DoWrite(NLog.ILogger logger, LogLevel level, string message)
        {
            switch (level)
            {
            case LogLevel.Debug:
                logger.Debug(message);
                break;

            case LogLevel.Info:
                logger.Info(message);
                break;

            case LogLevel.Warn:
                logger.Warn(message);
                break;

            case LogLevel.Error:
                logger.Error(message);
                break;

            case LogLevel.Fatal:
                logger.Fatal(message);
                break;

            default:
                throw new ArgumentException("不支持的日志级别", "level");
            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json", true, true)
                                    .Build();

            // NLog: setup the logger first to catch all errors
            NLog.LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration("nlog.config");
            NLog.ILogger logger = NLog.LogManager.Configuration.LogFactory.GetLogger("");

            string connection_string = config.GetConnectionString("mysql");

            IBackgroundTaskQueue <EventSummary> queue = new BackgroundTaskQueue <EventSummary>();
            EventHavestor eventHavestor = new EventHavestor(queue);

            MqttAddress queue_address = config.GetSection("MQTTBrokers").Get <MqttAddress>();

            Console.CancelKeyPress += Console_CancelKeyPress;

            EventRecorder eventRecorder = new EventRecorder(logger, queue, connection_string);

            Task T = eventHavestor.ConnectionAsync(queue_address.ClientId, queue_address.BindAddress, queue_address.Port, queue_address.QosLevel, queue_address.Topic);

            T.Wait();
            Task t1 = eventRecorder.RunAsync(cancellationTokenSource.Token);

            t1.Wait();
        }
Beispiel #7
0
 public SoundPlayer(NLog.ILogger logger)
 {
     _logger                  = logger;
     _musicPlayer             = new MediaPlayer();
     _musicPlayer.MediaEnded += MusicPlayer_MediaEnded;
     _repeat                  = false;
 }
 /// <summary>Initializes a new instance of the <see cref="UrlToXmlConverterService"/> class.</summary>
 /// <param name="reader">The reader.</param>
 /// <param name="writer">The writer.</param>
 /// <param name="transformer">The transformer.</param>
 public UrlToXmlConverterService(IReader <string> reader, IWriter <URLContainer> writer, ITransformer <URLContainer> transformer)
 {
     this.reader      = reader;
     this.writer      = writer;
     this.transformer = transformer;
     this.logger      = new WrongURLLogger().Logger;
 }
        public BluetoothApplicationClient()
        {
            this.Logger          = NLog.LogManager.GetLogger("BluetoothApplicationClient");
            this.KnownDeviceList = new List <DeviceInformation>();

            this.SendFileQueue    = new System.Collections.Concurrent.ConcurrentQueue <BluetoothApplicationTransferData>();
            this.ReceiveFileQueue = new System.Collections.Concurrent.ConcurrentQueue <BluetoothApplicationTransferData>();
        }
Beispiel #10
0
 public CodeItemsController(
     NLog.ILogger logger,
     ICodeItemService codeItemService, IUnitOfWorkAsync unitOfWork)
 {
     this.logger      = logger;
     _codeItemService = codeItemService;
     _unitOfWork      = unitOfWork;
 }
Beispiel #11
0
        public RedisClient(String connectionString, String clusterType, int monitorPort, int monitorIntervalMilliseconds)
        {
            this.config = ConfigurationOptions.Parse(connectionString);
            this.log    = NLog.LogManager.GetLogger(nameof(RedisClient));

            RedisConnect();
            RedisMonitor(clusterType, monitorPort, monitorIntervalMilliseconds);
        }
Beispiel #12
0
 public MenuItemsController(
     NLog.ILogger logger,
     IMenuItemService menuItemService, IUnitOfWorkAsync unitOfWork)
 {
     this.logger          = logger;
     this.menuItemService = menuItemService;
     this.unitOfWork      = unitOfWork;
 }
 public BluetoothApplicationServer()
 {
     this.Logger           = NLog.LogManager.GetLogger("BluetoothApplicationServer");
     this.SendFileQueue    = new System.Collections.Concurrent.ConcurrentQueue <BluetoothApplicationTransferData>();
     this.ReceiveFileQueue = new System.Collections.Concurrent.ConcurrentQueue <BluetoothApplicationTransferData>();
     this.AcceptingFlag    = false;
     this.RunningFlag      = false;
 }
        protected void Initialize(IBasicDeviceConnection broker, NLog.ILogger log)
        {
            _log = log;

            _broker = broker;
            _broker.PublishReceived += HandleBrokerPublishReceived;
            _broker.Connected       += HandleBrokerConnected;
        }
 public JControllerBase(ILogger <TController> logger)
 {
     if (logger == null)
     {
         throw new ArgumentNullException(nameof(logger));
     }
     this.logger = logger;
     _fileLogger = NLog.LogManager.GetLogger("Log");
 }
Beispiel #16
0
        public NLogLog(NLog.ILogger log)
        {
            if (log == null)
            {
                throw new ArgumentNullException("log");
            }

            Log = log;
        }
Beispiel #17
0
        public LogsController(

            NLog.ILogger logger,
            ISqlSugarClient db
            )
        {
            this.logger = logger;
            this.db     = db;
        }
 public MovieListUpdateService(
     IMoviesModel moviesModel,
     NLog.ILogger logger,
     ISettingsService settings)
 {
     this.moviesModel = moviesModel;
     this.logger      = logger;
     this.settings    = settings;
 }
Beispiel #19
0
        public NLogLogger(NLog.ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            _logger = logger;
        }
Beispiel #20
0
        public static NLogToMSLogAdapter GetAdapter(NLog.ILogger logger)
        {
            if (_adapter == null)
            {
                _adapter = new NLogToMSLogAdapter(logger);
            }

            return(_adapter);
        }
Beispiel #21
0
		public PackageService(
			IServerPackageRepository repository,
			IPackageAuthenticationService authenticationService,
			NLog.ILogger logger)
		{
			_serverRepository = repository;
			_authenticationService = authenticationService;
			_logger = logger;
		}
Beispiel #22
0
 public MoviesController(
     IMoviesModel moviesModel,
     NLog.ILogger logger,
     ISettingsService settings)
 {
     this.moviesModel = moviesModel;
     this.logger      = logger;
     this.settings    = settings;
 }
        public virtual NLog.ILogger GetCallSequenceLogger()
        {
            if (_callSequenceLogger == null)
            {
                _callSequenceLogger = YetiLog.GetCallSequenceLogger();
            }

            return(_callSequenceLogger);
        }
Beispiel #24
0
 public CommentsController(
     ICommentService commentService,
     IUnitOfWorkAsync unitOfWork,
     NLog.ILogger logger
     )
 {
     this.commentService = commentService;
     this.unitOfWork     = unitOfWork;
     this.logger         = logger;
 }
 public NLogLogger(NLog.ILogger logger)
 {
     _internalLogger = logger;
     IsTraceEnabled  = _internalLogger.IsTraceEnabled;
     IsDebugEnabled  = _internalLogger.IsDebugEnabled;
     IsInfoEnabled   = _internalLogger.IsInfoEnabled;
     IsWarnEnabled   = _internalLogger.IsWarnEnabled;
     IsErrorEnabled  = _internalLogger.IsErrorEnabled;
     IsFatalEnabled  = _internalLogger.IsFatalEnabled;
 }
Beispiel #26
0
 public AttachmentsController(
     IAttachmentService attachmentService,
     IUnitOfWorkAsync unitOfWork,
     NLog.ILogger logger
     )
 {
     this.attachmentService = attachmentService;
     this.unitOfWork        = unitOfWork;
     this.logger            = logger;
 }
Beispiel #27
0
		public StocksController (
          IStockService  stockService, 
          IUnitOfWorkAsync unitOfWork,
          NLog.ILogger logger
          )
		{
			this.stockService  = stockService;
			this.unitOfWork = unitOfWork;
            this.logger = logger;
		}
Beispiel #28
0
 public CanvasModule(BaseModule module)
 {
     Initialize(module);
     logger = NLog.LogManager.GetLogger("Canvas-" + module.DisplayName);
     logger.Info("Creating object 2 ClassName=CanvasModule");
     this.TextBoxDisplayName.KeyDown           += DisplayName_KeyDown;
     this.TextBoxDisplayName.LostKeyboardFocus += DisplayName_LostKeyboardFocus;
     //this.MaxWidth = 80;
     // this.MaxHeight = 120;
 }
Beispiel #29
0
 public BookPicturesController(
     IBookPictureService bookPictureService,
     IUnitOfWorkAsync unitOfWork,
     NLog.ILogger logger
     )
 {
     this.bookPictureService = bookPictureService;
     this.unitOfWork         = unitOfWork;
     this.logger             = logger;
 }
Beispiel #30
0
        public JiraImporter(NLog.ILogger logger,
                            AtbCalendar atbCalendar,
//             DirectumIssueStrategy directumIssueStrategy, DirectumRegistryChangeStrategy directumRegistryChangeStrategy,
                            IEnumerable <IDirectumIssueStrategyImport> strategies
                            )
        {
            _logger      = logger;
            _atbCalendar = atbCalendar;
            _strategies  = strategies;
        }
Beispiel #31
0
 public CheckOutsController(
     ICheckOutService checkOutService,
     IUnitOfWorkAsync unitOfWork,
     NLog.ILogger logger
     )
 {
     this.checkOutService = checkOutService;
     this.unitOfWork      = unitOfWork;
     this.logger          = logger;
 }
        public UsersController(IUOW uow, NLog.ILogger logger, ApplicationRoleManager roleManager, ApplicationSignInManager signInManager, ApplicationUserManager userManager, IAuthenticationManager authenticationManager)
        {
            _logger = logger;
            _roleManager = roleManager;
            _signInManager = signInManager;
            _userManager = userManager;
            _authenticationManager = authenticationManager;
            _uow = uow;

            _logger.Debug("InstanceId: " + _instanceId);
        }
Beispiel #33
0
        public PlatformManager(IMenuManager menuManager, IThreadManager threadManager, ILogger logger, IDependencyResolver resolver)
        {
            _menuManager = menuManager;
            _threadManager = threadManager;
            _resolver = resolver;
            _logger = logger;

            var systems = _menuManager.Systems;

            // populate platforms when system change
            systems.Changed
                .Skip(1)
                .ObserveOn(Scheduler.Default)
                .Subscribe(UpdatePlatforms);

            // populate platform when games change
            systems.Changed
                .ObserveOn(Scheduler.Default)
                .SelectMany(_ => systems
                    .Select(system => system.Games.Changed.Select(__ => system))
                .Merge())
            .Subscribe(UpdatePlatform);
        }
 public Logger(INLogger logger)
 {
     _logger = logger;
 }
 public NlogLoggerAdapter(NLog.ILogger logger)
 {
     _logger = logger;
 }
Beispiel #36
0
 public NLogLogger(NLog.ILogger internaLogger)
 {
     _internaLogger = internaLogger;
 }
Beispiel #37
0
 public NLogLogger(ILogger log)
 {
     this.logger = log;
 }
 public EmbeddedLogger(string name)
 {
     _logger = NLog.LogManager.GetLogger(name);
 }
Beispiel #39
0
        public GameItemViewModel(Game game, IDependencyResolver resolver)
        {
            Game = game;

            _logger = resolver.GetService<ILogger>();
            _vpdbClient = resolver.GetService<IVpdbClient>();
            _gameManager = resolver.GetService<IGameManager>();
            _messageManager = resolver.GetService<IMessageManager>();
            var threadManager = resolver.GetService<IThreadManager>();

            // release identify
            IdentifyRelease = ReactiveCommand.CreateAsyncObservable(_ => _vpdbClient.Api.GetReleasesBySize(Game.FileSize, MatchThreshold).SubscribeOn(threadManager.WorkerScheduler));
            IdentifyRelease.Select(releases => releases
                .Select(release => new {release, release.Versions})
                .SelectMany(x => x.Versions.Select(version => new {x.release, version, version.Files}))
                .SelectMany(x => x.Files.Select(file => new GameResultItemViewModel(game, x.release, x.version, file, CloseResults)))
            ).Subscribe(x => {

                var releases = x as GameResultItemViewModel[] ?? x.ToArray();
                var numMatches = 0;
                _logger.Info("Found {0} releases for game to identify.", releases.Length);
                GameResultItemViewModel match = null;
                foreach (var vm in releases) {
                    if (game.Filename == vm.TableFile.Reference.Name && game.FileSize == vm.TableFile.Reference.Bytes) {
                        numMatches++;
                        match = vm;
                    }
                }
                _logger.Info("Found {0} identical match(es).", numMatches);

                // if file name and file size are identical, directly match.
                if (numMatches == 1 && match != null) {
                    _logger.Info("File name and size are equal to local release, linking.");
                    _gameManager.LinkRelease(match.Game, match.Release, match.TableFile.Reference.Id);
                    _messageManager.LogReleaseLinked(match.Game, match.Release, match.TableFile.Reference.Id);

                } else {
                    _logger.Info("View model updated with identified releases.");
                    IdentifiedReleases = releases;
                    HasExecuted = true;
                }
            }, exception => _vpdbClient.HandleApiError(exception, "identifying a game by file size"));

            //SyncToggled
            //	.Where(_ => Game.IsSynced && Game.HasRelease)
            //	.Subscribe(_ => { GameManager.Sync(Game); });

            // handle errors
            IdentifyRelease.ThrownExceptions.Subscribe(e => { _logger.Error(e, "Error matching game."); });

            // spinner
            IdentifyRelease.IsExecuting.ToProperty(this, vm => vm.IsExecuting, out _isExecuting);

            // result switch
            IdentifyRelease.Select(r => r.Count > 0).Subscribe(hasResults => { HasResults = hasResults; });

            // close button
            CloseResults.Subscribe(_ => { HasExecuted = false; });

            // identify button visibility
            this.WhenAny(
                vm => vm.HasExecuted,
                vm => vm.Game.HasRelease,
                vm => vm.IsExecuting,
                (hasExecuted, hasRelease, isExecuting) => !hasExecuted.Value && !hasRelease.Value && !isExecuting.Value
            ).ToProperty(this, vm => vm.ShowIdentifyButton, out _showIdentifyButton);
        }
 /// <summary>
 ///     Log to the provided NLog <see cref="NLog.ILogger" />.
 /// </summary>
 /// <param name="configuration">The bus configuration to apply the logger to.</param>
 /// <param name="logger">The logger. Defaults to Serilogs static logger.</param>
 /// <returns>Bus configuration.</returns>
 public static BusBuilderConfiguration.Config WithSerilogLogger(this BusBuilderConfiguration.Config configuration, INLogger logger)
 {
     return configuration
         .WithLogger(new Logger(logger));
 }
Beispiel #41
0
 public TestActor()
 {
     _logger = NLog.LogManager.GetLogger("TestActor");
 }