logcast-sh 0.1.5 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19ba946f624ed2c806ad0b8f047a91bdb61e9638ed08543a7dbd4546be116850
4
- data.tar.gz: 20e3b34d6f784d07c62de9f0c44e056248b108cb2992f75bf85377550c1c218a
3
+ metadata.gz: 2abbb027e4f484fdb55763372b62bcc49e0f59ac584c01dedd92780ae3a66575
4
+ data.tar.gz: 39094a85cb09c4ae82f316b0deeb0ffcda3cb50a4e721232944a1ca0e944447d
5
5
  SHA512:
6
- metadata.gz: 7f6818780daa7403dece74cc9cd553753c5287fede291bedc5d2c8b3ab85f9b10f149d395b1971f459894188471d3ff8f35afd5d3a5d6034dc7573e670647124
7
- data.tar.gz: 36ceef4d7b57c0788daa09c232c6603aa0ae4273575549d87d984fe2f9ed8e257600942fc42f42d85d63b4c28df523c15cdbf2eaa6416db301ad0a8ddfbbc1f4
6
+ metadata.gz: 0f68f934e2fed25304f8e2725e902bb252662121d46265dfe56b905e4a572dff6c846db9b472925c4e385bb2412dd72ecb130cbd2173afc1450665c5b3accf70
7
+ data.tar.gz: e0c75fc18b8c2edca863e4be3c38a0768abf50beee5482769f4e124714d864f723d1b8a1f37ec4693a4111ec517bfce257cd39242f3629942546d857ed3d430f
data/README.md CHANGED
@@ -29,7 +29,7 @@ gem install logcast
29
29
 
30
30
  ## Quick Start
31
31
 
32
- 1. Get your API key from [logcast.dev](https://www.logcast.sh)
32
+ 1. Get your API key from [logcast.sh](https://www.logcast.sh)
33
33
 
34
34
  2. Create an initializer:
35
35
 
@@ -37,6 +37,7 @@ gem install logcast
37
37
  # config/initializers/logcast.rb
38
38
  Logcast.configure do |config|
39
39
  config.api_key = ENV["LOGCAST_API_KEY"]
40
+ config.enabled = Rails.env.production?
40
41
  end
41
42
  ```
42
43
 
@@ -55,7 +56,6 @@ That's it. Your Rails logs now flow to Logcast automatically — no other code c
55
56
  ```ruby
56
57
  Logcast.configure do |config|
57
58
  config.api_key = ENV["LOGCAST_API_KEY"]
58
- config.url = "https://www.logcast.sh" # default
59
59
  config.flush_interval = 5 # seconds, default
60
60
  config.batch_size = 100 # default
61
61
  config.enabled = true # default
data/lib/logcast-sh.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "logcast_sh"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Logcast
3
+ module LogcastSh
4
4
  class Buffer
5
5
  def initialize(batch_size:, flush_interval:, &on_flush)
6
6
  @batch_size = batch_size
@@ -35,7 +35,7 @@ module Logcast
35
35
 
36
36
  @on_flush.call(batch) if batch
37
37
  rescue => e
38
- $stderr.puts "[Logcast] Flush error: #{e.message}"
38
+ $stderr.puts "[LogcastSh] Flush error: #{e.message}"
39
39
  end
40
40
 
41
41
  def stop
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Logcast
3
+ module LogcastSh
4
4
  class Configuration
5
5
  attr_accessor :api_key, :url, :batch_size, :flush_interval, :enabled
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Logcast
3
+ module LogcastSh
4
4
  class LogSubscriber
5
5
  SEVERITY_MAP = {
6
6
  0 => "debug",
@@ -33,7 +33,7 @@ module Logcast
33
33
  end
34
34
 
35
35
  if message
36
- Logcast.push({
36
+ LogcastSh.push({
37
37
  "level" => SEVERITY_MAP[severity] || "unknown",
38
38
  "message" => message.to_s.gsub(/\e\[[0-9;]*m/, ""),
39
39
  "metadata" => {},
@@ -86,7 +86,7 @@ module Logcast
86
86
  msg = message || (block ? block.call : progname)
87
87
 
88
88
  if msg
89
- Logcast.push({
89
+ LogcastSh.push({
90
90
  "level" => severity_map[severity] || "unknown",
91
91
  "message" => msg.to_s,
92
92
  "metadata" => {},
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LogcastSh
4
+ class Railtie < Rails::Railtie
5
+ config.after_initialize do
6
+ if LogcastSh.configuration.api_key && LogcastSh.enabled?
7
+ LogcastSh.start!
8
+ LogcastSh.attach_logger!(Rails.logger)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -4,7 +4,7 @@ require "net/http"
4
4
  require "uri"
5
5
  require "json"
6
6
 
7
- module Logcast
7
+ module LogcastSh
8
8
  class Transport
9
9
  CONNECT_TIMEOUT = 5
10
10
  READ_TIMEOUT = 10
@@ -25,10 +25,10 @@ module Logcast
25
25
  response = http.request(request)
26
26
 
27
27
  unless response.is_a?(Net::HTTPSuccess)
28
- $stderr.puts "[Logcast] Ingest API responded with #{response.code}: #{response.body}"
28
+ $stderr.puts "[LogcastSh] Ingest API responded with #{response.code}: #{response.body}"
29
29
  end
30
30
  rescue => e
31
- $stderr.puts "[Logcast] Transport error: #{e.message}"
31
+ $stderr.puts "[LogcastSh] Transport error: #{e.message}"
32
32
  end
33
33
  end
34
34
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LogcastSh
4
+ VERSION = "0.2.0"
5
+ end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "logcast/version"
4
- require_relative "logcast/configuration"
5
- require_relative "logcast/buffer"
6
- require_relative "logcast/transport"
7
- require_relative "logcast/log_subscriber"
3
+ require_relative "logcast_sh/version"
4
+ require_relative "logcast_sh/configuration"
5
+ require_relative "logcast_sh/buffer"
6
+ require_relative "logcast_sh/transport"
7
+ require_relative "logcast_sh/log_subscriber"
8
8
 
9
- module Logcast
9
+ module LogcastSh
10
10
  class Error < StandardError; end
11
11
 
12
12
  class << self
@@ -73,4 +73,4 @@ module Logcast
73
73
  end
74
74
  end
75
75
 
76
- require_relative "logcast/railtie" if defined?(Rails::Railtie)
76
+ require_relative "logcast_sh/railtie" if defined?(Rails::Railtie)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logcast-sh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Jeon
@@ -24,13 +24,14 @@ files:
24
24
  - LICENSE.txt
25
25
  - README.md
26
26
  - Rakefile
27
- - lib/logcast.rb
28
- - lib/logcast/buffer.rb
29
- - lib/logcast/configuration.rb
30
- - lib/logcast/log_subscriber.rb
31
- - lib/logcast/railtie.rb
32
- - lib/logcast/transport.rb
33
- - lib/logcast/version.rb
27
+ - lib/logcast-sh.rb
28
+ - lib/logcast_sh.rb
29
+ - lib/logcast_sh/buffer.rb
30
+ - lib/logcast_sh/configuration.rb
31
+ - lib/logcast_sh/log_subscriber.rb
32
+ - lib/logcast_sh/railtie.rb
33
+ - lib/logcast_sh/transport.rb
34
+ - lib/logcast_sh/version.rb
34
35
  - sig/logcast.rbs
35
36
  homepage: https://www.logcast.sh
36
37
  licenses:
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Logcast
4
- class Railtie < Rails::Railtie
5
- config.after_initialize do
6
- if Logcast.configuration.api_key && Logcast.enabled?
7
- Logcast.start!
8
- Logcast.attach_logger!(Rails.logger)
9
- end
10
- end
11
- end
12
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Logcast
4
- VERSION = "0.1.5"
5
- end