td-logger 0.3.28 → 0.4.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 +8 -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 -31
- 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: 3509dc779f96051e1170ff12bf6daea73c97a036aed00fbd7f1ccca8c0cd772d
|
4
|
+
data.tar.gz: cca38604bf79e9fd0132bdd225e0b97a198d47a6413aef80a01b3b5b88a70955
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a417ee2218848ba7273693dedee44976c5f90282801fdcb091f15f6f9ec3013553c7bdd06f77fb948f65f3f3683a87a09dc072e6216962a32a23ffe2b78473c
|
7
|
+
data.tar.gz: c46d6e0cea7a883399a213d0e6ffb725c83759692e5193fb9c4716da51446ac02935ff700b475842f3e78768950bcd6347460ba569b3a213b0b2872f387deda0
|
data/ChangeLog
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 2025-04-14 version 0.4.0
|
2
|
+
|
3
|
+
* Require Ruby 2.7 or higher. Support for versions earlier than 2.7 has been removed.
|
4
|
+
* Require td-client v1.0.8+
|
5
|
+
* Allow td-client v2.x
|
6
|
+
* Add mutex_m gem for Ruby 3.3+
|
7
|
+
* Add logger gem
|
8
|
+
|
1
9
|
== 2022-06-23 version 0.3.28
|
2
10
|
|
3
11
|
* 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.4.0
|
data/lib/td/logger/td_logger.rb
CHANGED
data/lib/td/logger/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -36,20 +36,20 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.8
|
39
|
+
version: 1.0.8
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '3.0'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.8
|
49
|
+
version: 1.0.8
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '3.0'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: fluent-logger
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,6 +70,40 @@ dependencies:
|
|
70
70
|
- - "<"
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '2.0'
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: mutex_m
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.2.0
|
80
|
+
- - "<"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.2.0
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '1.0'
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: logger
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
type: :runtime
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
73
107
|
- !ruby/object:Gem::Dependency
|
74
108
|
name: rake
|
75
109
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,14 +166,9 @@ executables: []
|
|
132
166
|
extensions: []
|
133
167
|
extra_rdoc_files: []
|
134
168
|
files:
|
135
|
-
- ".coveralls.yml"
|
136
|
-
- ".github/workflows/ci.yml"
|
137
|
-
- ".github/workflows/codeql-analysis.yml"
|
138
|
-
- ".gitignore"
|
139
169
|
- ChangeLog
|
140
|
-
- Gemfile
|
141
170
|
- README.rdoc
|
142
|
-
-
|
171
|
+
- SECURITY.md
|
143
172
|
- VERSION
|
144
173
|
- config/heroku/treasure_data.yml
|
145
174
|
- lib/td-logger.rb
|
@@ -153,14 +182,6 @@ files:
|
|
153
182
|
- lib/td/logger/event.rb
|
154
183
|
- lib/td/logger/td_logger.rb
|
155
184
|
- 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
185
|
homepage:
|
165
186
|
licenses:
|
166
187
|
- Apache-2.0
|
@@ -173,22 +194,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
194
|
requirements:
|
174
195
|
- - ">="
|
175
196
|
- !ruby/object:Gem::Version
|
176
|
-
version:
|
197
|
+
version: 2.7.0
|
177
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
199
|
requirements:
|
179
200
|
- - ">="
|
180
201
|
- !ruby/object:Gem::Version
|
181
202
|
version: '0'
|
182
203
|
requirements: []
|
183
|
-
rubygems_version: 3.3.
|
204
|
+
rubygems_version: 3.3.26
|
184
205
|
signing_key:
|
185
206
|
specification_version: 4
|
186
207
|
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
|
208
|
+
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
|