コード例 #1
0
        public static void Log(string message, Exception exception = null,
                               object additional = null, string language = null)
        {
            if (_client == null)
            {
                _client = GetClient();
            }

            var logEvent = new LogglyEvent();

            logEvent.Data.Add("version", GetExecutingAssemblyVersion());
            logEvent.Data.Add("message", message);

            if (exception != null)
            {
                logEvent.Data.Add("exception", exception);
            }

            if (additional != null)
            {
                logEvent.Data.Add("additional", additional);
            }

            _client.Log(logEvent);
        }
コード例 #2
0
 public override void ActivateOptions()
 {
     base.ActivateOptions();
     _formatter = _formatter ?? (_config.UseRawFormatter ? (ILogglyFormatter) new RawLogglyFormatter(_config) : new LogglyFormatter(_config));
     _client    = new LogglyClient(_config);
     _buffer    = _buffer ?? new LogglyAsyncBuffer(_config, _client);
 }
コード例 #3
0
        public void Message_is_not_published_after_adding_to_queue_when_disposed([Frozen] ILogglyClient client, LogglyProcessor sut, LogglyMessage message)
        {
            sut.Dispose();

            sut.EnqueueMessage(message);

            Mock.Get(client).Verify(p => p.PublishAsync(message), Times.Never);
        }
コード例 #4
0
        public async Task Message_is_published_after_adding_to_queue([Frozen] ILogglyClient client, LogglyProcessor sut, LogglyMessage message)
        {
            sut.EnqueueMessage(message);

            await Task.Delay(TimeSpan.FromMilliseconds(100));

            Mock.Get(client).Verify(p => p.PublishManyAsync(It.Is <IEnumerable <LogglyMessage> >(m => m.Contains(message))));
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClientAppSettingsController"/> class.
 /// </summary>
 /// <param name="options"></param>
 /// <param name="logglyClient"></param>
 public ClientAppSettingsController(IOptions <ApplicationOptions> options, ILogglyClient logglyClient)
 {
     _configurationOptions = options.Value;
     _logglyClient         = logglyClient;
     _logglyEvent          = new LogglyEvent();
     _logglyEvent.Options.Tags.Add(new SimpleTag {
         Value = "ClientAppSettings"
     });
 }
コード例 #6
0
        public LogglyAsyncBuffer(Config config, ILogglyClient client)
        {
            _config = config;
            _client = client;
            var sendingThread = new Thread(DoSend)
            {
                Name         = "LogglySendThread",
                IsBackground = true
            };

            sendingThread.Start();
        }
コード例 #7
0
ファイル: LogHelper.cs プロジェクト: JPG-Consulting/TSVN
        public static void Log(object log)
        {
            if (_client == null)
            {
                _client = GetClient();
            }

            var logEvent = new LogglyEvent();

            logEvent.Data.Add("version", GetExecutingAssemblyVersion());
            logEvent.Data.Add("message", log);
            _client.Log(logEvent);
        }
コード例 #8
0
ファイル: LogHelper.cs プロジェクト: JPG-Consulting/TSVN
        public static void Log(Exception e)
        {
            if (_client == null)
            {
                _client = GetClient();
            }

            var logEvent = new LogglyEvent();

            logEvent.Data.Add("version", GetExecutingAssemblyVersion());
            logEvent.Data.Add("exception", e);
            _client.Log(logEvent);
        }
コード例 #9
0
        /// <inheritdoc />
        protected override void InitializeTarget()
        {
            var customerToken = CustomerToken?.Render(LogEventInfo.CreateNullEvent());

            if (!string.IsNullOrWhiteSpace(customerToken))
            {
                LogglyConfig.Instance.CustomerToken = customerToken;

                var applicationName = ApplicationName?.Render(LogEventInfo.CreateNullEvent());
                if (!string.IsNullOrWhiteSpace(applicationName))
                {
                    LogglyConfig.Instance.ApplicationName = applicationName;
                }
            }

            var endPointHostName = EndpointHostname?.Render(LogEventInfo.CreateNullEvent());

            if (!string.IsNullOrWhiteSpace(endPointHostName))
            {
                var endpointPort = EndpointPort?.Render(LogEventInfo.CreateNullEvent());
                if (!int.TryParse(endpointPort ?? string.Empty, out var endpointPortNumber))
                {
                    endpointPortNumber = 0; // Let Loggly guess from LogTransport-enum
                }

                var forwardedForIp = ForwardedForIp?.Render(LogEventInfo.CreateNullEvent());
                if (string.IsNullOrEmpty(forwardedForIp))
                {
                    forwardedForIp = null;
                }

                LogglyConfig.Instance.Transport = new TransportConfiguration()
                {
                    EndpointHostname = endPointHostName,
                    EndpointPort     = endpointPortNumber,
                    LogTransport     = LogTransport,
                    ForwardedForIp   = forwardedForIp,
                }.GetCoercedToValidConfig();
            }

            base.InitializeTarget();
            _pendingTaskCount = 0;
            _client           = ClientFactory.Invoke();
        }
コード例 #10
0
        static LogglyFacade()
        {
            var instance = LogglyConfig.Instance;

            if (String.IsNullOrEmpty(instance.ApplicationName))
            {
                instance.ApplicationName = GlobalSettingsFacade.ApplicationName;
            }

            var tags = instance.TagConfig.Tags;

            tags.Add(new ApplicationNameTag
            {
                Formatter = "application-{0}"
            });

            tags.Add(new InstallationIdTag
            {
                Formatter = "installation-{0}"
            });

            Client = new LogglyClient();
        }
コード例 #11
0
 protected override void CloseTarget()
 {
     _client = null;
     base.CloseTarget();
 }
コード例 #12
0
 protected override void InitializeTarget()
 {
     base.InitializeTarget();
     _pendingTaskCount = 0;
     _client           = ClientFactory.Invoke();
 }
コード例 #13
0
        public LogglyProcessor(ILogglyClient client)
        {
            _client = client ?? throw new ArgumentNullException(nameof(client));

            _subscription = _messageSubject.Buffer(TimeSpan.FromMilliseconds(50)).Subscribe(ProcessLogQueue);
        }
コード例 #14
0
 protected BaseTest()
 {
     _logglyConfig = ReadConfigFromFile();
     _logglyClient = new LogglyClient(_logglyConfig);
 }