logkit 0.1.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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +68 -0
  3. data/lib/logkit/version.rb +5 -0
  4. data/lib/logkit.rb +32 -0
  5. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 73647846f52c59d3282cfebaa228bdf05a0be8d883c5de812dcd04f09537ee85
4
+ data.tar.gz: c16e11f14bf5a3050bef2c75e6d9f998d1c24555790bfe2ba6580b767ae9818a
5
+ SHA512:
6
+ metadata.gz: cd1ec8121cc63245c2a174cedd43d843bbba5957826826d8f3ffaab22b83fb20a1c4a479ae9872686217da32de5a76432dd17c62bf649acee9cc7c95c786e4f7
7
+ data.tar.gz: 11bdbd0ac43cd9065c7f752bd1f652483b58bac745af3ad939e5fbfb7303c7078f084e160163ca43d95981357c03019d458616a3d5ca3b33e4e14cb72fcc0365
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # Logkit
2
+
3
+ Logkit is a Ruby client for logging events to Logkit. It provides a simple interface to send data from your Ruby or Ruby on Rails application to your Logkit endpoint.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```bash
10
+ gem 'logkit'
11
+ ```
12
+
13
+
14
+ And then execute:
15
+
16
+ ```bash
17
+ bundle install
18
+ ```
19
+
20
+ Or install it yourself as:
21
+
22
+ ```bash
23
+ gem install logkit
24
+ ```
25
+
26
+ ## Configuration
27
+
28
+ ### Ruby on Rails
29
+
30
+ To configure the gem in a Rails application, you'll want to set up an initializer file where you can configure the logkit_url and other settings.
31
+
32
+ Create a file config/initializers/logkit.rb:
33
+
34
+ ```rb
35
+ # config/initializers/logkit.rb
36
+ require 'logkit'
37
+
38
+ Logkit::Client.logkit_url = "https://your-logkit-endpoint.com"
39
+ Logkit::Client.mode = Rails.env.production? ? "prod" : "dev"
40
+ ```
41
+
42
+
43
+ This configuration sets the Logkit URL and adjusts the logging mode based on the environment. In production, it logs to the Logkit service, and in development or test environments, it logs to the console.
44
+
45
+ ## Usage
46
+
47
+ To log events, simply call the log method anywhere in your Rails application:
48
+
49
+ ```rb
50
+ Logkit::Client.log("event_name", { key: "value" })
51
+ ```
52
+
53
+ This will send an event named event_name with the provided payload to the configured Logkit endpoint.
54
+
55
+ ## Development
56
+
57
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run rake test to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
58
+
59
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
60
+
61
+ ## Contributing
62
+
63
+ Bug reports and pull requests are welcome on GitHub at https://github.com/philipp-spiess/logkit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
64
+
65
+ ## License
66
+
67
+ The gem is available as open source under the terms of the MIT License.
68
+
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Logkit
4
+ VERSION = "0.1.0"
5
+ end
data/lib/logkit.rb ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "logkit/version"
4
+
5
+ module Logkit
6
+ class Error < StandardError; end
7
+
8
+ class Client
9
+ @logkit_url = nil
10
+ @mode = "prod"
11
+
12
+ class << self
13
+ attr_accessor :logkit_url, :mode
14
+
15
+ def log(event, payload)
16
+ return if @logkit_url.nil?
17
+
18
+ if @mode == "dev"
19
+ puts "[logkit] #{event}: #{payload}"
20
+ else
21
+ uri = URI(@logkit_url)
22
+ http = Net::HTTP.new(uri.host, uri.port)
23
+ http.use_ssl = true if uri.scheme == "https"
24
+ request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
25
+ request.body = { event: event, payload: payload, mode: @mode }.to_json
26
+ response = http.request(request)
27
+ puts response.body
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logkit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Philipp Spiess
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-04-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Next generation logging infrastructure
14
+ email:
15
+ - hello@philippspiess.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.md
21
+ - lib/logkit.rb
22
+ - lib/logkit/version.rb
23
+ homepage: https://logkit.co
24
+ licenses:
25
+ - MIT
26
+ metadata:
27
+ homepage_uri: https://logkit.co
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 3.0.0
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.5.3
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Ruby client for Logkit
47
+ test_files: []