logtail 0.1.11 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +15 -11
- data/README.md +12 -59
- data/example-project/Gemfile +1 -1
- data/example-project/Gemfile.lock +2 -2
- data/example-project/main.rb +6 -0
- data/lib/logtail/config.rb +22 -0
- data/lib/logtail/log_devices/http.rb +2 -0
- data/lib/logtail/log_entry.rb +2 -2
- data/lib/logtail/version.rb +1 -1
- data/logtail.gemspec +1 -1
- metadata +3 -4
- data/CHANGELOG.md +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10c467039aa517fd668eb0b4f25a3bc0405331b9c422984b01e7effa7bfd1ceb
|
4
|
+
data.tar.gz: 2890f2588f6beb9671037e0521a3eb361e80937e0c475b4be2f2895e48422540
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81d0c6479082f302ff146cb321f9483c6b46a8d2fbf9133e1c661bc9694f5d8134447a2ec6d8ab7bfbc6ee36abc66fabe0777e113b199dc31642810fbfee7322
|
7
|
+
data.tar.gz: 161f16cd44e8522fe9c6e47b31773a2d422372ac082409d3afaec74ba249807af1a51512fcb1c151eb5541ad45cbbfc82d62eccde03231b25129abe0dfda232e
|
data/.github/workflows/main.yml
CHANGED
@@ -1,24 +1,28 @@
|
|
1
1
|
name: build
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
schedule:
|
6
|
+
- cron: '20 5 * * 1'
|
7
|
+
workflow_dispatch:
|
4
8
|
|
5
9
|
jobs:
|
6
10
|
test:
|
7
|
-
|
8
11
|
runs-on: ubuntu-20.04
|
9
12
|
|
10
13
|
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
|
11
16
|
matrix:
|
12
17
|
ruby-version:
|
13
|
-
- 3.2
|
14
|
-
- 3.1
|
15
|
-
- 3.0
|
16
|
-
- 2.7
|
17
|
-
- 2.6
|
18
|
-
- 2.5
|
19
|
-
- 2.4
|
20
|
-
- 2.3
|
21
|
-
- 2.2.10
|
18
|
+
- 3.2
|
19
|
+
- 3.1
|
20
|
+
- 3.0
|
21
|
+
- 2.7
|
22
|
+
- 2.6
|
23
|
+
- 2.5
|
24
|
+
- 2.4
|
25
|
+
- 2.3
|
22
26
|
- jruby-9.4.3.0
|
23
27
|
- jruby-9.2.14.0
|
24
28
|
- truffleruby-23.0.0
|
data/README.md
CHANGED
@@ -1,69 +1,22 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
[![Logtail ruby dashboard](https://user-images.githubusercontent.com/19272921/154085622-59997d5a-3f91-4bc9-a815-3b8ead16d28d.jpeg)](https://betterstack.com/logtail)
|
1
|
+
# [Better Stack](https://betterstack.com/logs) Ruby client
|
4
2
|
|
5
|
-
[
|
6
|
-
[![Gem Version](https://badge.fury.io/rb/logtail-ruby.svg)](https://badge.fury.io/rb/logtail-ruby)
|
7
|
-
[![Build Status](https://github.com/logtail/logtail-ruby/workflows/build/badge.svg)](https://github.com/logtail/logtail-ruby/actions?query=workflow%3Abuild)
|
8
|
-
|
9
|
-
Collect logs directly from your Ruby projects. To start logging Ruby on Rails projects explore the [Logtail Rails library](https://github.com/logtail/logtail-ruby-rails).
|
10
|
-
|
11
|
-
[Logtail](https://betterstack.com/logtail) is a hosted service that centralizes all of your logs into one place. Allowing for analysis, correlation and filtering with SQL. Actionable Grafana dashboards and collaboration come built-in. Logtail works with [any language or platform and any data source](https://docs.logtail.com/).
|
12
|
-
|
13
|
-
### Features
|
14
|
-
- Simple integration.
|
15
|
-
- Support for structured logging and events.
|
16
|
-
- Automatically captures useful context.
|
17
|
-
- Performant, light weight, with a thoughtful design.
|
18
|
-
|
19
|
-
### Supported language versions
|
20
|
-
- Ruby 2.7.0 or newer
|
21
|
-
|
22
|
-
# Installation
|
23
|
-
Install the Logtail Ruby client library, run the following command:
|
24
|
-
|
25
|
-
```bash
|
26
|
-
bundle add logtail
|
27
|
-
```
|
28
|
-
|
29
|
-
This will install Logtail gem and create `Gemfile` and `Gemfile.lock` that are used to track the code dependencies.
|
3
|
+
📣 Logtail is now part of Better Stack. [Learn more ⇗](https://betterstack.com/press/introducing-better-stack/)
|
30
4
|
|
31
|
-
|
5
|
+
[![Better Stack dashboard](https://github.com/logtail/logtail-python/assets/10132717/e2a1196b-7924-4abc-9b85-055e17b5d499)](https://betterstack.com/logs)
|
32
6
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
To help you get started with using Logtail in your Ruby projects, we have prepared a simple program that showcases the usage of Logtail logger.
|
38
|
-
|
39
|
-
## Download and install the example project
|
40
|
-
|
41
|
-
You can download the [example project](https://github.com/logtail/logtail-ruby/tree/main/example-project) from GitHub directly or you can clone it to a select directory. Make sure you are in the projects directory and run the following command:
|
42
|
-
|
43
|
-
```bash
|
44
|
-
bundle install
|
45
|
-
```
|
46
|
-
|
47
|
-
This will install all dependencies listed in the `Gemfile.lock` file.
|
7
|
+
[![ISC License](https://img.shields.io/badge/license-ISC-ff69b4.svg)](LICENSE.md)
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/logtail.svg)](https://badge.fury.io/rb/logtail)
|
9
|
+
[![Build Status](https://github.com/logtail/logtail-ruby/workflows/build/badge.svg)](https://github.com/logtail/logtail-ruby/actions?query=workflow%3Abuild)
|
48
10
|
|
49
|
-
|
50
|
-
|
51
|
-
To run the example application, run the following command:
|
11
|
+
Experience SQL-compatible structured log management based on ClickHouse. [Learn more ⇗](https://betterstack.com/logs)
|
52
12
|
|
53
|
-
|
54
|
-
bundle exec ruby main.rb <source-token>
|
55
|
-
```
|
13
|
+
## Documentation
|
56
14
|
|
57
|
-
|
15
|
+
[Getting started ⇗](https://betterstack.com/docs/logs/ruby-and-rails/#logging-from-ruby)
|
58
16
|
|
59
|
-
|
17
|
+
## Need help?
|
18
|
+
Please let us know at [hello@betterstack.com](mailto:hello@betterstack.com). We're happy to help!
|
60
19
|
|
61
|
-
## Explore how example project works
|
62
|
-
|
63
|
-
Learn how to setup Ruby logging by exploring the workings of the [example project](https://github.com/logtail/logtail-ruby/tree/main/example-project) in detail.
|
64
|
-
|
65
20
|
---
|
66
|
-
|
67
|
-
## Get in touch
|
68
21
|
|
69
|
-
|
22
|
+
[ISC license](https://github.com/logtail/logtail-ruby/blob/main/LICENSE.md), [example project](https://github.com/logtail/logtail-ruby/tree/main/example-project)
|
data/example-project/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
gem "logtail"
|
2
|
+
gem "logtail", "~> 0.1.12"
|
data/example-project/main.rb
CHANGED
@@ -15,6 +15,9 @@ end
|
|
15
15
|
http_device = Logtail::LogDevices::HTTP.new(ARGV[0])
|
16
16
|
logger = Logtail::Logger.new(http_device)
|
17
17
|
|
18
|
+
# Filter logs that shouldn't be sent to Better Stack, see {Logtail::LogEntry} for available attributes
|
19
|
+
Logtail.config.filter_sent_to_better_stack { |log_entry| log_entry.message.include?("DO_NOT_SEND") }
|
20
|
+
|
18
21
|
# LOGGING
|
19
22
|
|
20
23
|
# Send debug logs messages using the debug() method
|
@@ -33,6 +36,9 @@ logger.warn(
|
|
33
36
|
}
|
34
37
|
)
|
35
38
|
|
39
|
+
# Some messages can be filtered, see {Logtail::Config#filter_sent_to_better_stack} call above
|
40
|
+
logger.info("This message will not be sent to Better Stack because it contains 'DO_NOT_SEND'")
|
41
|
+
|
36
42
|
# Send error messages using the error() method
|
37
43
|
logger.error("Oops! An error occurred!")
|
38
44
|
|
data/lib/logtail/config.rb
CHANGED
@@ -32,6 +32,28 @@ module Logtail
|
|
32
32
|
|
33
33
|
attr_writer :http_body_limit
|
34
34
|
|
35
|
+
# Whether a particular {Logtail::LogEntry} should be sent to Better Stack
|
36
|
+
def send_to_better_stack?(log_entry)
|
37
|
+
!@better_stack_filters&.any? { |blocker| blocker.call(log_entry) }
|
38
|
+
rescue => e
|
39
|
+
debug { "Could not determine whether to send LogEntry to Better Stack (assumed yes): #{e}" }
|
40
|
+
true
|
41
|
+
end
|
42
|
+
|
43
|
+
# This allows filtering logs that are sent to Better Stack. Can be called multiple times, all filters will
|
44
|
+
# be applied. If the passed block RETURNS TRUE for a particular LogEntry, it WILL NOT BE SENT to Better Stack.
|
45
|
+
#
|
46
|
+
# See {Logtail::LogEntry} for available attributes of the block parameter.
|
47
|
+
#
|
48
|
+
# @example Rails
|
49
|
+
# config.logtail.filter_sent_to_better_stack { |log_entry| log_entry.context_snapshot[:http][:path].start_with?('/_') }
|
50
|
+
# @example Everything else
|
51
|
+
# Logtail.config.filter_sent_to_better_stack { |log_entry| log_entry.message.include?('IGNORE') }
|
52
|
+
def filter_sent_to_better_stack(&block)
|
53
|
+
@better_stack_filters ||= []
|
54
|
+
@better_stack_filters << -> (log_entry) { yield(log_entry) }
|
55
|
+
end
|
56
|
+
|
35
57
|
# Convenience method for logging debug statements to the debug logger
|
36
58
|
# set in this class.
|
37
59
|
# @private
|
@@ -89,6 +89,8 @@ module Logtail
|
|
89
89
|
# size is constricted by the Logtail API. The actual application limit is a multiple
|
90
90
|
# of this. Hence the `@request_queue`.
|
91
91
|
def write(msg)
|
92
|
+
return unless Logtail.config.send_to_better_stack?(msg)
|
93
|
+
|
92
94
|
@msg_queue.enq(msg)
|
93
95
|
|
94
96
|
# Lazily start flush threads to ensure threads are alive after forking processes.
|
data/lib/logtail/log_entry.rb
CHANGED
@@ -134,13 +134,13 @@ module Logtail
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def logtail_logger_frame?(frame)
|
137
|
-
!frame.
|
137
|
+
!frame.path.nil? && frame.path.end_with?(LOGGER_FILE)
|
138
138
|
end
|
139
139
|
|
140
140
|
def path_relative_to_app_root(frame)
|
141
141
|
Pathname.new(frame.absolute_path).relative_path_from(root_path).to_s
|
142
142
|
rescue
|
143
|
-
frame.absolute_path
|
143
|
+
frame.absolute_path || frame.path
|
144
144
|
end
|
145
145
|
|
146
146
|
def root_path
|
data/lib/logtail/version.rb
CHANGED
data/logtail.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.metadata["homepage_uri"] = spec.homepage
|
19
19
|
spec.metadata["source_code_uri"] = spec.homepage
|
20
20
|
|
21
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
21
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3")
|
22
22
|
|
23
23
|
spec.files = `git ls-files`.split("\n")
|
24
24
|
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logtail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Better Stack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -146,7 +146,6 @@ files:
|
|
146
146
|
- ".github/workflows/main.yml"
|
147
147
|
- ".gitignore"
|
148
148
|
- ".rspec"
|
149
|
-
- CHANGELOG.md
|
150
149
|
- Gemfile
|
151
150
|
- LICENSE.md
|
152
151
|
- README.md
|
@@ -216,7 +215,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
215
|
requirements:
|
217
216
|
- - ">="
|
218
217
|
- !ruby/object:Gem::Version
|
219
|
-
version: 2.
|
218
|
+
version: '2.3'
|
220
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
220
|
requirements:
|
222
221
|
- - ">="
|
data/CHANGELOG.md
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
All notable changes to this project will be documented in this file.
|
4
|
-
|
5
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
6
|
-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
7
|
-
|
8
|
-
## [Unreleased]
|
9
|
-
|
10
|
-
## [0.1.0] - 2021-02-11
|
11
|
-
|
12
|
-
- The first version of the client.
|
13
|
-
|
14
|
-
## [0.1.2] - 2021-04-22
|
15
|
-
|
16
|
-
- Fixed string encoding.
|
17
|
-
|
18
|
-
## [0.1.3] - 2021-06-11
|
19
|
-
|
20
|
-
- Fixed detection of the frame that calls the logger.
|
21
|
-
|
22
|
-
## [0.1.7] - 2021-08-16
|
23
|
-
|
24
|
-
- Fixed runtime context's frame label encoding.
|
25
|
-
|
26
|
-
## [0.1.8] - 2023-01-16
|
27
|
-
|
28
|
-
- Fix issue where message is lost when logging hashes with multiple IO devices (thanks @olivier-thatch!)
|