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); }
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); }
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); }
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)))); }
/// <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" }); }
public LogglyAsyncBuffer(Config config, ILogglyClient client) { _config = config; _client = client; var sendingThread = new Thread(DoSend) { Name = "LogglySendThread", IsBackground = true }; sendingThread.Start(); }
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); }
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); }
/// <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(); }
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(); }
protected override void CloseTarget() { _client = null; base.CloseTarget(); }
protected override void InitializeTarget() { base.InitializeTarget(); _pendingTaskCount = 0; _client = ClientFactory.Invoke(); }
public LogglyProcessor(ILogglyClient client) { _client = client ?? throw new ArgumentNullException(nameof(client)); _subscription = _messageSubject.Buffer(TimeSpan.FromMilliseconds(50)).Subscribe(ProcessLogQueue); }
protected BaseTest() { _logglyConfig = ReadConfigFromFile(); _logglyClient = new LogglyClient(_logglyConfig); }