td-logger 0.3.28 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +12 -0
- data/SECURITY.md +7 -0
- data/VERSION +1 -1
- data/lib/td/logger/td_logger.rb +1 -0
- data/lib/td/logger/version.rb +1 -1
- metadata +45 -36
- data/.coveralls.yml +0 -1
- data/.github/workflows/ci.yml +0 -44
- data/.github/workflows/codeql-analysis.yml +0 -70
- data/.gitignore +0 -4
- data/Gemfile +0 -3
- data/Rakefile +0 -13
- data/spec/spec_helper.rb +0 -29
- data/spec/td/logger/agent/config_spec.rb +0 -260
- data/spec/td/logger/agent/rack_spec.rb +0 -37
- data/spec/td/logger/agent/rails_spec.rb +0 -155
- data/spec/td/logger/event_spec.rb +0 -136
- data/spec/td/logger/treasure_data_logger_spec.rb +0 -669
- data/spec/td/logger_spec.rb +0 -128
- data/td-logger.gemspec +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8d34fbd552bd218ffed8aeba1ef1b6f92fb5115a400b56be7472a58691c7230
|
4
|
+
data.tar.gz: 8e9051c8f64c275f8ba88d050699c29a9516c43273adf96a4a981895fd1bcfd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10c275985d05660a840b9cd6d3391395e9b560f0bb9d07a4c883854b6c6b0a4ff8d243be022fbf0274d67270790c5400851464f3a87782563c8c1afcef636585
|
7
|
+
data.tar.gz: 64989473b1aea22cd96ec45c3ce29033661537a192f5790a2c94ae43cfd2116efde926b8a858022cda74f37a2d6b9fb89eb430e2eef57f0b71dbe206091e11ca
|
data/ChangeLog
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
== 2025-05-08 version 0.5.0
|
2
|
+
|
3
|
+
* Add support for td-client v3.x
|
4
|
+
|
5
|
+
== 2025-04-14 version 0.4.0
|
6
|
+
|
7
|
+
* Require Ruby 2.7 or higher. Support for versions earlier than 2.7 has been removed.
|
8
|
+
* Require td-client v1.0.8+
|
9
|
+
* Allow td-client v2.x
|
10
|
+
* Add mutex_m gem for Ruby 3.3+
|
11
|
+
* Add logger gem
|
12
|
+
|
1
13
|
== 2022-06-23 version 0.3.28
|
2
14
|
|
3
15
|
* Support Ruby 3.1 (psych 4.0): Allow loading configuration files (tresure_data.yml) which have YAML aliases.
|
data/SECURITY.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Reporting a Vulnerability
|
4
|
+
|
5
|
+
Treasure Data values the security of its customers and is committed to ensuring that the systems and products are secure. We invite all bug bounty researchers to join our efforts in identifying and reporting vulnerabilities in our systems.
|
6
|
+
|
7
|
+
Submit your findings to our dedicated bug bounty email address [vulnerabilities@treasuredata.com](mailto:vulnerabilities@treasuredata.com) and help us keep Treasure Data secure. Let’s work together to make the Internet a safer place!
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/td/logger/td_logger.rb
CHANGED
data/lib/td/logger/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
|
-
|
9
|
-
bindir: bin
|
8
|
+
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: msgpack
|
@@ -36,20 +35,20 @@ dependencies:
|
|
36
35
|
requirements:
|
37
36
|
- - ">="
|
38
37
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.8
|
38
|
+
version: 1.0.8
|
40
39
|
- - "<"
|
41
40
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
41
|
+
version: '4.0'
|
43
42
|
type: :runtime
|
44
43
|
prerelease: false
|
45
44
|
version_requirements: !ruby/object:Gem::Requirement
|
46
45
|
requirements:
|
47
46
|
- - ">="
|
48
47
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.8
|
48
|
+
version: 1.0.8
|
50
49
|
- - "<"
|
51
50
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
51
|
+
version: '4.0'
|
53
52
|
- !ruby/object:Gem::Dependency
|
54
53
|
name: fluent-logger
|
55
54
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,6 +69,40 @@ dependencies:
|
|
70
69
|
- - "<"
|
71
70
|
- !ruby/object:Gem::Version
|
72
71
|
version: '2.0'
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: mutex_m
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 0.2.0
|
79
|
+
- - "<"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.0'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.2.0
|
89
|
+
- - "<"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '1.0'
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: logger
|
94
|
+
requirement: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
73
106
|
- !ruby/object:Gem::Dependency
|
74
107
|
name: rake
|
75
108
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,19 +160,13 @@ dependencies:
|
|
127
160
|
- !ruby/object:Gem::Version
|
128
161
|
version: '0'
|
129
162
|
description: Treasure Data logging library
|
130
|
-
email:
|
131
163
|
executables: []
|
132
164
|
extensions: []
|
133
165
|
extra_rdoc_files: []
|
134
166
|
files:
|
135
|
-
- ".coveralls.yml"
|
136
|
-
- ".github/workflows/ci.yml"
|
137
|
-
- ".github/workflows/codeql-analysis.yml"
|
138
|
-
- ".gitignore"
|
139
167
|
- ChangeLog
|
140
|
-
- Gemfile
|
141
168
|
- README.rdoc
|
142
|
-
-
|
169
|
+
- SECURITY.md
|
143
170
|
- VERSION
|
144
171
|
- config/heroku/treasure_data.yml
|
145
172
|
- lib/td-logger.rb
|
@@ -153,19 +180,9 @@ files:
|
|
153
180
|
- lib/td/logger/event.rb
|
154
181
|
- lib/td/logger/td_logger.rb
|
155
182
|
- lib/td/logger/version.rb
|
156
|
-
- spec/spec_helper.rb
|
157
|
-
- spec/td/logger/agent/config_spec.rb
|
158
|
-
- spec/td/logger/agent/rack_spec.rb
|
159
|
-
- spec/td/logger/agent/rails_spec.rb
|
160
|
-
- spec/td/logger/event_spec.rb
|
161
|
-
- spec/td/logger/treasure_data_logger_spec.rb
|
162
|
-
- spec/td/logger_spec.rb
|
163
|
-
- td-logger.gemspec
|
164
|
-
homepage:
|
165
183
|
licenses:
|
166
184
|
- Apache-2.0
|
167
185
|
metadata: {}
|
168
|
-
post_install_message:
|
169
186
|
rdoc_options: []
|
170
187
|
require_paths:
|
171
188
|
- lib
|
@@ -173,22 +190,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
190
|
requirements:
|
174
191
|
- - ">="
|
175
192
|
- !ruby/object:Gem::Version
|
176
|
-
version:
|
193
|
+
version: 2.7.0
|
177
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
195
|
requirements:
|
179
196
|
- - ">="
|
180
197
|
- !ruby/object:Gem::Version
|
181
198
|
version: '0'
|
182
199
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
184
|
-
signing_key:
|
200
|
+
rubygems_version: 3.6.7
|
185
201
|
specification_version: 4
|
186
202
|
summary: Treasure Data logging library
|
187
|
-
test_files:
|
188
|
-
- spec/spec_helper.rb
|
189
|
-
- spec/td/logger/agent/config_spec.rb
|
190
|
-
- spec/td/logger/agent/rack_spec.rb
|
191
|
-
- spec/td/logger/agent/rails_spec.rb
|
192
|
-
- spec/td/logger/event_spec.rb
|
193
|
-
- spec/td/logger/treasure_data_logger_spec.rb
|
194
|
-
- spec/td/logger_spec.rb
|
203
|
+
test_files: []
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|
data/.github/workflows/ci.yml
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
name: CI
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
|
6
|
-
jobs:
|
7
|
-
test:
|
8
|
-
runs-on: ${{ matrix.os }}
|
9
|
-
|
10
|
-
strategy:
|
11
|
-
matrix:
|
12
|
-
os:
|
13
|
-
- ubuntu-latest
|
14
|
-
ruby:
|
15
|
-
- 2.3.1
|
16
|
-
- 2.4.1
|
17
|
-
- 2.5.9
|
18
|
-
- 2.6.9
|
19
|
-
- 2.7.5
|
20
|
-
- 3.0.3
|
21
|
-
- 3.1.0
|
22
|
-
- head
|
23
|
-
# TODO: Add jruby
|
24
|
-
include:
|
25
|
-
- os: windows-latest
|
26
|
-
ruby: 2.7.5
|
27
|
-
- os: macos-latest
|
28
|
-
ruby: 2.7.5
|
29
|
-
|
30
|
-
|
31
|
-
steps:
|
32
|
-
- uses: actions/checkout@v2
|
33
|
-
- name: Set up Ruby
|
34
|
-
uses: ruby/setup-ruby@v1
|
35
|
-
with:
|
36
|
-
ruby-version: ${{ matrix.ruby }}
|
37
|
-
|
38
|
-
- name: Install dependencies
|
39
|
-
run: |
|
40
|
-
bundle config path vendor/bundle
|
41
|
-
bundle install --jobs 4 --retry 3
|
42
|
-
|
43
|
-
- name: Run tests
|
44
|
-
run: bundle exec rake spec
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# For most projects, this workflow file will not need changing; you simply need
|
2
|
-
# to commit it to your repository.
|
3
|
-
#
|
4
|
-
# You may wish to alter this file to override the set of languages analyzed,
|
5
|
-
# or to provide custom queries or build logic.
|
6
|
-
#
|
7
|
-
# ******** NOTE ********
|
8
|
-
# We have attempted to detect the languages in your repository. Please check
|
9
|
-
# the `language` matrix defined below to confirm you have the correct set of
|
10
|
-
# supported CodeQL languages.
|
11
|
-
#
|
12
|
-
name: "CodeQL"
|
13
|
-
|
14
|
-
on:
|
15
|
-
push:
|
16
|
-
branches: [ master ]
|
17
|
-
pull_request:
|
18
|
-
# The branches below must be a subset of the branches above
|
19
|
-
branches: [ master ]
|
20
|
-
schedule:
|
21
|
-
- cron: '39 1 * * 6'
|
22
|
-
|
23
|
-
jobs:
|
24
|
-
analyze:
|
25
|
-
name: Analyze
|
26
|
-
runs-on: ubuntu-latest
|
27
|
-
permissions:
|
28
|
-
actions: read
|
29
|
-
contents: read
|
30
|
-
security-events: write
|
31
|
-
|
32
|
-
strategy:
|
33
|
-
fail-fast: false
|
34
|
-
matrix:
|
35
|
-
language: [ 'ruby' ]
|
36
|
-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
37
|
-
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
38
|
-
|
39
|
-
steps:
|
40
|
-
- name: Checkout repository
|
41
|
-
uses: actions/checkout@v3
|
42
|
-
|
43
|
-
# Initializes the CodeQL tools for scanning.
|
44
|
-
- name: Initialize CodeQL
|
45
|
-
uses: github/codeql-action/init@v1
|
46
|
-
with:
|
47
|
-
languages: ${{ matrix.language }}
|
48
|
-
# If you wish to specify custom queries, you can do so here or in a config file.
|
49
|
-
# By default, queries listed here will override any specified in a config file.
|
50
|
-
# Prefix the list here with "+" to use these queries and those in the config file.
|
51
|
-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
52
|
-
|
53
|
-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
54
|
-
# If this step fails, then you should remove it and run the build manually (see below)
|
55
|
-
- name: Autobuild
|
56
|
-
uses: github/codeql-action/autobuild@v1
|
57
|
-
|
58
|
-
# ℹ️ Command-line programs to run using the OS shell.
|
59
|
-
# 📚 https://git.io/JvXDl
|
60
|
-
|
61
|
-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
62
|
-
# and modify them (or add more) to build your code if your project
|
63
|
-
# uses a compiled language
|
64
|
-
|
65
|
-
#- run: |
|
66
|
-
# make bootstrap
|
67
|
-
# make release
|
68
|
-
|
69
|
-
- name: Perform CodeQL Analysis
|
70
|
-
uses: github/codeql-action/analyze@v1
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
if defined?(:RUBY_ENGINE) && RUBY_ENGINE == 'ruby'
|
2
|
-
# SimpleCov officially supports MRI 1.9+ only for now
|
3
|
-
# https://github.com/colszowka/simplecov#ruby-version-compatibility
|
4
|
-
|
5
|
-
require 'simplecov'
|
6
|
-
unless ENV['APPVEYOR']
|
7
|
-
require 'coveralls'
|
8
|
-
|
9
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
10
|
-
SimpleCov::Formatter::HTMLFormatter,
|
11
|
-
Coveralls::SimpleCov::Formatter
|
12
|
-
]
|
13
|
-
end
|
14
|
-
SimpleCov.start("test_frameworks")
|
15
|
-
end
|
16
|
-
|
17
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
18
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
19
|
-
|
20
|
-
REPO_ROOT = Pathname.new(File.expand_path("../", __FILE__))
|
21
|
-
|
22
|
-
require 'td-logger'
|
23
|
-
|
24
|
-
RSpec.configure do |config|
|
25
|
-
#config.filter_run :focus => true
|
26
|
-
config.run_all_when_everything_filtered = true
|
27
|
-
|
28
|
-
config.mock_with :rspec
|
29
|
-
end
|
@@ -1,260 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'logger'
|
4
|
-
|
5
|
-
TMP_DIR = REPO_ROOT.join("tmp")
|
6
|
-
FileUtils.rm_rf(TMP_DIR)
|
7
|
-
|
8
|
-
class Rails
|
9
|
-
def self.configuration
|
10
|
-
self.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.logger
|
14
|
-
Logger.new(STDOUT)
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.root
|
18
|
-
TMP_DIR
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.env
|
22
|
-
"test"
|
23
|
-
end
|
24
|
-
|
25
|
-
def middleware
|
26
|
-
self
|
27
|
-
end
|
28
|
-
|
29
|
-
def use(mod)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class ActionController
|
34
|
-
class Base
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class ActiveSupport
|
39
|
-
class TimeWithZone
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
require 'td/logger/agent/rails' # NOTE: should be require after Rails goodies mocked
|
44
|
-
|
45
|
-
|
46
|
-
describe TreasureData::Logger::Agent::Rails::Config do
|
47
|
-
before(:each) do
|
48
|
-
FileUtils.rm_rf(TMP_DIR)
|
49
|
-
FileUtils.mkdir_p(TMP_DIR)
|
50
|
-
ENV.delete('TREASURE_DATA_API_KEY')
|
51
|
-
ENV.delete('TREASURE_DATA_DB')
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'init' do
|
55
|
-
it 'load_env' do
|
56
|
-
ENV['TREASURE_DATA_API_KEY'] = 'test1'
|
57
|
-
ENV['TREASURE_DATA_DB'] = 'db1'
|
58
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
59
|
-
expect(c.disabled).to eq(false)
|
60
|
-
expect(c.agent_mode?).to eq(false)
|
61
|
-
expect(c.apikey).to eq('test1')
|
62
|
-
expect(c.database).to eq('db1')
|
63
|
-
expect(c.auto_create_table).to eq(true)
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'load_file' do
|
67
|
-
FileUtils.mkdir_p("#{TMP_DIR}/config")
|
68
|
-
File.open("#{TMP_DIR}/config/treasure_data.yml", "w") {|f|
|
69
|
-
f.write <<EOF
|
70
|
-
test:
|
71
|
-
apikey: test2
|
72
|
-
database: db2
|
73
|
-
debug_mode: true
|
74
|
-
EOF
|
75
|
-
}
|
76
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
77
|
-
expect(c.disabled).to eq(false)
|
78
|
-
expect(c.agent_mode?).to eq(false)
|
79
|
-
expect(c.apikey).to eq('test2')
|
80
|
-
expect(c.database).to eq('db2')
|
81
|
-
expect(c.auto_create_table).to eq(true)
|
82
|
-
expect(c.debug_mode).to eq(true)
|
83
|
-
expect(c.access_log_enabled?).to eq false
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'load_file without test' do
|
87
|
-
FileUtils.mkdir_p("#{TMP_DIR}/config")
|
88
|
-
File.open("#{TMP_DIR}/config/treasure_data.yml", "w") {|f|
|
89
|
-
f.write <<EOF
|
90
|
-
development:
|
91
|
-
apikey: test2
|
92
|
-
database: db2
|
93
|
-
debug_mode: true
|
94
|
-
EOF
|
95
|
-
}
|
96
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
97
|
-
expect(c.disabled).to eq(true)
|
98
|
-
expect(c.access_log_enabled?).to eq false
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'prefer file than env' do
|
102
|
-
ENV['TREASURE_DATA_API_KEY'] = 'test3'
|
103
|
-
ENV['TREASURE_DATA_DB'] = 'db3'
|
104
|
-
|
105
|
-
FileUtils.mkdir_p("#{TMP_DIR}/config")
|
106
|
-
File.open("#{TMP_DIR}/config/treasure_data.yml", "w") {|f|
|
107
|
-
f.write <<EOF
|
108
|
-
test:
|
109
|
-
apikey: test4
|
110
|
-
database: db4
|
111
|
-
auto_create_table: false
|
112
|
-
EOF
|
113
|
-
}
|
114
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
115
|
-
expect(c.disabled).to eq(false)
|
116
|
-
expect(c.agent_mode?).to eq(false)
|
117
|
-
expect(c.apikey).to eq('test4')
|
118
|
-
expect(c.database).to eq('db4')
|
119
|
-
expect(c.auto_create_table).to eq(false)
|
120
|
-
expect(c.debug_mode).to eq(false)
|
121
|
-
expect(c.access_log_enabled?).to eq false
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'agent mode' do
|
125
|
-
FileUtils.mkdir_p("#{TMP_DIR}/config")
|
126
|
-
File.open("#{TMP_DIR}/config/treasure_data.yml", "w") {|f|
|
127
|
-
f.write <<EOF
|
128
|
-
test:
|
129
|
-
agent: localhost
|
130
|
-
tag: td.db5
|
131
|
-
EOF
|
132
|
-
}
|
133
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
134
|
-
expect(c.disabled).to eq(false)
|
135
|
-
expect(c.agent_mode?).to eq(true)
|
136
|
-
expect(c.tag).to eq('td.db5')
|
137
|
-
expect(c.agent_host).to eq('localhost')
|
138
|
-
expect(c.agent_port).to eq(24224)
|
139
|
-
expect(c.access_log_enabled?).to eq false
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'test mode' do
|
143
|
-
FileUtils.mkdir_p("#{TMP_DIR}/config")
|
144
|
-
File.open("#{TMP_DIR}/config/treasure_data.yml", "w") {|f|
|
145
|
-
f.write <<EOF
|
146
|
-
test:
|
147
|
-
agent: localhost
|
148
|
-
tag: td.db5
|
149
|
-
test_mode: true
|
150
|
-
EOF
|
151
|
-
}
|
152
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
153
|
-
expect(c.disabled).to eq(false)
|
154
|
-
expect(c.test_mode?).to eq(true)
|
155
|
-
expect(c.access_log_enabled?).to eq false
|
156
|
-
end
|
157
|
-
|
158
|
-
it "access_log_enabled" do
|
159
|
-
FileUtils.mkdir_p("#{TMP_DIR}/config")
|
160
|
-
File.open("#{TMP_DIR}/config/treasure_data.yml", "w") {|f|
|
161
|
-
f.write <<EOF
|
162
|
-
test:
|
163
|
-
agent: localhost
|
164
|
-
tag: foo.bar
|
165
|
-
access_log_table: log
|
166
|
-
EOF
|
167
|
-
}
|
168
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
169
|
-
expect(c.disabled).to eq(false)
|
170
|
-
expect(c.access_log_enabled?).to eq true
|
171
|
-
end
|
172
|
-
|
173
|
-
describe "load_file_ey" do
|
174
|
-
context "config_path does not exists" do
|
175
|
-
it "load from CONFIG_PATH_EY_DEPLOY" do
|
176
|
-
FileUtils.mkdir_p("#{TMP_DIR}/config")
|
177
|
-
File.unlink("#{TMP_DIR}/config/treasure_data.yml") rescue nil
|
178
|
-
File.open(TreasureData::Logger::Agent::Rails::CONFIG_PATH_EY_DEPLOY, "w") {|f|
|
179
|
-
f.write <<EOF
|
180
|
-
td:
|
181
|
-
TREASURE_DATA_API_KEY: foo
|
182
|
-
EOF
|
183
|
-
}
|
184
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
185
|
-
expect(c.disabled).to eq(false)
|
186
|
-
end
|
187
|
-
|
188
|
-
it "disabled true if td.TREASURE_DATA_API_KEY missing" do
|
189
|
-
FileUtils.mkdir_p("#{TMP_DIR}/config")
|
190
|
-
File.unlink("#{TMP_DIR}/config/treasure_data.yml") rescue nil
|
191
|
-
File.open(TreasureData::Logger::Agent::Rails::CONFIG_PATH_EY_DEPLOY, "w") {|f|
|
192
|
-
f.write <<EOF
|
193
|
-
EOF
|
194
|
-
}
|
195
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
196
|
-
expect(c.disabled).to eq(true)
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
context "config_path and CONFIG_PATH_EY_DEPLOY does not exists" do
|
201
|
-
it "load from CONFIG_PATH_EY_LOCAL" do
|
202
|
-
FileUtils.mkdir_p("#{TMP_DIR}/config")
|
203
|
-
File.unlink("#{TMP_DIR}/config/treasure_data.yml") rescue nil
|
204
|
-
File.unlink(TreasureData::Logger::Agent::Rails::CONFIG_PATH_EY_DEPLOY) rescue nil
|
205
|
-
File.open(TreasureData::Logger::Agent::Rails::CONFIG_PATH_EY_LOCAL, "w") {|f|
|
206
|
-
f.write <<EOF
|
207
|
-
td:
|
208
|
-
TREASURE_DATA_API_KEY: foo
|
209
|
-
EOF
|
210
|
-
}
|
211
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
212
|
-
expect(c.disabled).to eq(false)
|
213
|
-
end
|
214
|
-
|
215
|
-
it "disabled true if td.TREASURE_DATA_API_KEY missing" do
|
216
|
-
FileUtils.mkdir_p("#{TMP_DIR}/config")
|
217
|
-
File.unlink("#{TMP_DIR}/config/treasure_data.yml") rescue nil
|
218
|
-
File.open(TreasureData::Logger::Agent::Rails::CONFIG_PATH_EY_LOCAL, "w") {|f|
|
219
|
-
f.write <<EOF
|
220
|
-
EOF
|
221
|
-
}
|
222
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
223
|
-
expect(c.disabled).to eq(true)
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
context "config_path, CONFIG_PATH_EY_DEPLOY, CONFIG_PATH_EY_LOCAL are all exists" do
|
228
|
-
it "load from CONFIG_PATH_EY_LOCAL" do
|
229
|
-
FileUtils.mkdir_p("#{TMP_DIR}/config")
|
230
|
-
File.open("#{TMP_DIR}/config/treasure_data.yml", "w") {|f|
|
231
|
-
f.write <<EOF
|
232
|
-
test:
|
233
|
-
agent: localhost
|
234
|
-
tag: foo.bar
|
235
|
-
test_mode: false
|
236
|
-
EOF
|
237
|
-
}
|
238
|
-
File.open(TreasureData::Logger::Agent::Rails::CONFIG_PATH_EY_DEPLOY, "w") {|f|
|
239
|
-
f.write <<EOF
|
240
|
-
test:
|
241
|
-
agent: localhost
|
242
|
-
tag: foo.bar
|
243
|
-
test_mode: true
|
244
|
-
EOF
|
245
|
-
}
|
246
|
-
File.open(TreasureData::Logger::Agent::Rails::CONFIG_PATH_EY_LOCAL, "w") {|f|
|
247
|
-
f.write <<EOF
|
248
|
-
test:
|
249
|
-
agent: localhost
|
250
|
-
tag: foo.bar
|
251
|
-
test_mode: true
|
252
|
-
EOF
|
253
|
-
}
|
254
|
-
c = TreasureData::Logger::Agent::Rails::Config.init
|
255
|
-
expect(c.test_mode).to eq(false)
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require "rack/mock"
|
3
|
-
require 'td/logger/agent/rack'
|
4
|
-
|
5
|
-
describe TreasureData::Logger::Agent::Rack::Hook do
|
6
|
-
def app
|
7
|
-
@app ||= Rack::Builder.new {
|
8
|
-
use TreasureData::Logger::Agent::Rack::Hook
|
9
|
-
run lambda {|env| [200, {}, ["body"]]}
|
10
|
-
}.to_app
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:dummy_object) { double.as_null_object }
|
14
|
-
|
15
|
-
subject { Rack::MockRequest.new(app).get("/") }
|
16
|
-
|
17
|
-
describe ".before" do
|
18
|
-
it do
|
19
|
-
TreasureData::Logger::Agent::Rack::Hook.before do |env|
|
20
|
-
dummy_object.called_at_before!(env)
|
21
|
-
end
|
22
|
-
expect(subject.status).to eq 200
|
23
|
-
expect(dummy_object).to have_received(:called_at_before!).once
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe ".after" do
|
28
|
-
it do
|
29
|
-
TreasureData::Logger::Agent::Rack::Hook.after do |env, result|
|
30
|
-
dummy_object.called_at_after!
|
31
|
-
result[0] = 201
|
32
|
-
end
|
33
|
-
expect(subject.status).to eq 201
|
34
|
-
expect(dummy_object).to have_received(:called_at_after!).once
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|