From 7db9722e2e71a71171b329619d003f7df53fe434 Mon Sep 17 00:00:00 2001 From: Timothy Stott Date: Fri, 12 Aug 2016 15:32:39 +0100 Subject: [PATCH] Concatenate tags into String instead of Array to allow Graylog search --- README.md | 2 +- lib/loga/formatter.rb | 2 +- lib/loga/version.rb | 2 +- spec/fixtures/rails32/config/application.rb | 2 +- spec/fixtures/rails40/config/application.rb | 2 +- spec/integration/sinatra_spec.rb | 2 +- spec/support/request_spec.rb | 10 +++++----- spec/unit/loga/formatter_spec.rb | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 61cfb96..72643c0 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Loga.logger.info('Hello World') "level": 6, "_service.name": "marketplace", "_service.version": "v1.0.0", - "_tags": [] + "_tags": "" } ``` diff --git a/lib/loga/formatter.rb b/lib/loga/formatter.rb index c1d4106..d174a94 100644 --- a/lib/loga/formatter.rb +++ b/lib/loga/formatter.rb @@ -97,7 +97,7 @@ def loga_additional_fields name: @service_name, version: @service_version, }, - tags: current_tags, + tags: current_tags.join(' '), } end end diff --git a/lib/loga/version.rb b/lib/loga/version.rb index 0a71874..099e91b 100644 --- a/lib/loga/version.rb +++ b/lib/loga/version.rb @@ -1,3 +1,3 @@ module Loga - VERSION = '1.1.1'.freeze + VERSION = '1.2.1'.freeze end diff --git a/spec/fixtures/rails32/config/application.rb b/spec/fixtures/rails32/config/application.rb index 301219b..0b37c87 100644 --- a/spec/fixtures/rails32/config/application.rb +++ b/spec/fixtures/rails32/config/application.rb @@ -60,7 +60,7 @@ class Application < Rails::Application # in your app. As such, your models will need to explicitly whitelist or blacklist accessible # parameters by using an attr_accessible or attr_protected declaration. # config.active_record.whitelist_attributes = true - config.log_tags = [:uuid] + config.log_tags = [ :uuid, 'TEST_TAG' ] config.loga.configure do |loga| loga.service_name = 'hello_world_app' loga.service_version = '1.0' diff --git a/spec/fixtures/rails40/config/application.rb b/spec/fixtures/rails40/config/application.rb index b2277d9..f4c2547 100644 --- a/spec/fixtures/rails40/config/application.rb +++ b/spec/fixtures/rails40/config/application.rb @@ -26,7 +26,7 @@ class Application < Rails::Application # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - config.log_tags = [:uuid] + config.log_tags = [ :uuid, 'TEST_TAG' ] config.loga.configure do |loga| loga.service_name = 'hello_world_app' loga.service_version = '1.0' diff --git a/spec/integration/sinatra_spec.rb b/spec/integration/sinatra_spec.rb index b4df29d..b45d26f 100644 --- a/spec/integration/sinatra_spec.rb +++ b/spec/integration/sinatra_spec.rb @@ -24,7 +24,7 @@ set :show_exceptions, false use Loga::Rack::RequestId - use Loga::Rack::Logger, Loga.logger, [:uuid] + use Loga::Rack::Logger, Loga.logger, [:uuid, 'TEST_TAG'] error do status 500 diff --git a/spec/support/request_spec.rb b/spec/support/request_spec.rb index eca7ba0..41e0a85 100644 --- a/spec/support/request_spec.rb +++ b/spec/support/request_spec.rb @@ -22,7 +22,7 @@ '_request.status' => 200, '_request.request_id' => '471a34dc', '_request.duration' => 0, - '_tags' => ['471a34dc'], + '_tags' => '471a34dc TEST_TAG', ) end end @@ -52,7 +52,7 @@ '_request.status' => 200, '_request.request_id' => '471a34dc', '_request.duration' => 0, - '_tags' => ['471a34dc'], + '_tags' => '471a34dc TEST_TAG', ) end @@ -83,7 +83,7 @@ '_request.status' => 302, '_request.request_id' => '471a34dc', '_request.duration' => 0, - '_tags' => ['471a34dc'], + '_tags' => '471a34dc TEST_TAG', ) end end @@ -114,7 +114,7 @@ '_exception.klass' => 'NoMethodError', '_exception.message' => "undefined method `name' for nil:NilClass", '_exception.backtrace' => be_a(String), - '_tags' => ['471a34dc'], + '_tags' => '471a34dc TEST_TAG', ) end end @@ -140,7 +140,7 @@ '_request.status' => 404, '_request.request_id' => '471a34dc', '_request.duration' => 0, - '_tags' => ['471a34dc'], + '_tags' => '471a34dc TEST_TAG', ) end end diff --git a/spec/unit/loga/formatter_spec.rb b/spec/unit/loga/formatter_spec.rb index dfb84d6..66843bc 100644 --- a/spec/unit/loga/formatter_spec.rb +++ b/spec/unit/loga/formatter_spec.rb @@ -26,7 +26,7 @@ it 'includes Loga additional fields' do expect(json).to include('_service.name' => service_name, '_service.version' => service_version, - '_tags' => []) + '_tags' => '') end it 'outputs the timestamp in seconds since UNIX epoch' do