Skip to content

Commit b809ef6

Browse files
📝 Rename api_key to source_token (#4)
1 parent 10bfec2 commit b809ef6

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def puts_with_level(message, level = :info)
1414
end
1515
end
1616

17-
task :test_the_pipes, [:api_key] do |t, args|
17+
task :test_the_pipes, [:source_token] do |t, args|
1818
support_email = "[email protected]"
1919
# Do not modify below this line. It's important to keep the `Logtail::Logger`
2020
# because it provides an API for logging structured data and capturing context.
@@ -26,7 +26,7 @@ task :test_the_pipes, [:api_key] do |t, args|
2626

2727
current_context = Logtail::CurrentContext.instance.snapshot
2828
entry = Logtail::LogEntry.new(:info, Time.now, nil, "Testing the pipes (click the inspect icon to view more details)", current_context, nil)
29-
http_device = Logtail::LogDevices::HTTP.new(args.api_key, flush_continuously: false)
29+
http_device = Logtail::LogDevices::HTTP.new(args.source_token, flush_continuously: false)
3030
response = http_device.deliver_one(entry)
3131
if response.is_a?(Exception)
3232
message = <<~HEREDOC

lib/logtail/log_devices/http.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class HTTP
3636
# you can drop the log messages instead by passing a {DroppingSizedQueue} via the
3737
# `:request_queue` option.
3838
#
39-
# @param api_key [String] The API key provided to you after you add your application to
39+
# @param source_token [String] The API key provided to you after you add your application to
4040
# [Logtail](https://logtail.com).
4141
# @param [Hash] options the options to create a HTTP log device with.
4242
# @option attributes [Symbol] :batch_size (1000) Determines the maximum of log lines in
@@ -64,13 +64,13 @@ class HTTP
6464
# The default is set via {LOGTAIL_HOST}.
6565
#
6666
# @example Basic usage
67-
# Logtail::Logger.new(Logtail::LogDevices::HTTP.new("my_logtail_api_key"))
67+
# Logtail::Logger.new(Logtail::LogDevices::HTTP.new("my_logtail_source_token"))
6868
#
6969
# @example Apply back pressure instead of dropping messages
70-
# http_log_device = Logtail::LogDevices::HTTP.new("my_logtail_api_key", request_queue: SizedQueue.new(25))
70+
# http_log_device = Logtail::LogDevices::HTTP.new("my_logtail_source_token", request_queue: SizedQueue.new(25))
7171
# Logtail::Logger.new(http_log_device)
72-
def initialize(api_key, options = {})
73-
@api_key = api_key || raise(ArgumentError.new("The api_key parameter cannot be blank"))
72+
def initialize(source_token, options = {})
73+
@source_token = source_token || raise(ArgumentError.new("The source_token parameter cannot be blank"))
7474
@logtail_host = options[:logtail_host] || ENV['LOGTAIL_HOST'] || LOGTAIL_HOST
7575
@logtail_port = options[:logtail_port] || ENV['LOGTAIL_PORT'] || LOGTAIL_PORT
7676
@logtail_scheme = options[:logtail_scheme] || ENV['LOGTAIL_SCHEME'] || LOGTAIL_SCHEME
@@ -168,7 +168,7 @@ def verify_delivery!
168168
end
169169

170170
raise <<-MESSAGE
171-
171+
172172
Log delivery failed! No request was made.
173173
174174
You can enable internal debug logging with the following:
@@ -361,7 +361,7 @@ def deliver_requests(conn)
361361

362362
# Builds the `Authorization` header value for HTTP delivery to the Logtail API.
363363
def authorization_payload
364-
"Bearer #{@api_key}"
364+
"Bearer #{@source_token}"
365365
end
366366
end
367367
end

lib/logtail/logger.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ def call(severity, time, progname, msg)
135135
# logger = Logtail::Logger.new(STDOUT)
136136
#
137137
# @example Logging to the Logtail HTTP device
138-
# http_device = Logtail::LogDevices::HTTP.new("my-logtail-api-key")
138+
# http_device = Logtail::LogDevices::HTTP.new("my-logtail-source-token")
139139
# logger = Logtail::Logger.new(http_device)
140140
#
141141
# @example Logging to a file (with rotation)
142142
# file_device = Logger::LogDevice.new("path/to/file.log")
143143
# logger = Logtail::Logger.new(file_device)
144144
#
145145
# @example Logging to a file and the Logtail HTTP device (multiple log devices)
146-
# http_device = Logtail::LogDevices::HTTP.new("my-logtail-api-key")
146+
# http_device = Logtail::LogDevices::HTTP.new("my-logtail-source-token")
147147
# file_logger = ::Logger.new("path/to/file.log")
148148
# logger = Logtail::Logger.new(http_device, file_logger)
149149
def initialize(*io_devices_and_loggers)

spec/logtail/logger_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
end
162162

163163
context "with the HTTP log device" do
164-
let(:io) { Logtail::LogDevices::HTTP.new("my_key") }
164+
let(:io) { Logtail::LogDevices::HTTP.new("my_source_token") }
165165

166166
it "should use the PassThroughFormatter" do
167167
expect(logger.formatter).to be_kind_of(Logtail::Logger::PassThroughFormatter)
@@ -189,7 +189,7 @@
189189

190190
describe "#formatter=" do
191191
it "should not allow changing the formatter when the device is HTTP" do
192-
http_device = Logtail::LogDevices::HTTP.new("api_key")
192+
http_device = Logtail::LogDevices::HTTP.new("source_token")
193193
logger = Logtail::Logger.new(http_device)
194194
expect { logger.formatter = ::Logger::Formatter.new }.to raise_error(ArgumentError)
195195
end

0 commit comments

Comments
 (0)