|
1 | | -# 🪵 Logtail Integration For Rack |
| 1 | +# [Better Stack](https://betterstack.com/logs) Rack client |
2 | 2 |
|
3 | | - [](https://betterstack.com/logtail) |
| 3 | +📣 Logtail is now part of Better Stack. [Learn more ⇗](https://betterstack.com/press/introducing-better-stack/) |
| 4 | + |
| 5 | +[](https://betterstack.com/logs) |
4 | 6 |
|
5 | 7 | [](LICENSE.md) |
6 | 8 | [](https://badge.fury.io/rb/logtail-rack) |
7 | 9 | [](https://github.com/logtail/logtail-ruby-rack/actions/workflows/main.yml) |
8 | 10 |
|
9 | | -This library integrates the [`logtail` Ruby library](https://github.com/logtail/logtail-ruby) with the [rack](https://github.com/rack/rack) framework, |
10 | | -turning your Rack logs into rich structured events. |
11 | | - |
12 | | -* **Sign-up: [https://logs.betterstack.com](https://logs.betterstack.com)** |
13 | | - |
14 | | -Collect logs directly from your Ruby Rack projects. To start logging Ruby projects explore the [Logtail Ruby library](https://github.com/logtail/logtail-ruby). |
15 | | - |
16 | | -[Better Stack](https://logs.betterstack.com) is a hosted service that centralizes all of your logs into one place. |
17 | | -Allowing for analysis, correlation and filtering with SQL. |
18 | | -Actionable Grafana dashboards and collaboration come built-in. |
19 | | -Logtail works with [any language or platform and any data source](https://betterstack.com/docs/logs/). |
20 | | - |
21 | | -### Features |
22 | | -- Simple integration. |
23 | | -- Support for structured logging and events. |
24 | | -- Automatically captures useful context. |
25 | | -- Performant, light weight, with a thoughtful design. |
26 | | - |
27 | | -### Supported language versions |
28 | | -- Ruby 2.3 or newer |
29 | | -- Rack 1.2 or newer |
30 | | - |
31 | | -# Installation |
32 | | -Install the Logtail Rack client library, run the following command: |
33 | | - |
34 | | -```bash |
35 | | -bundle add logtail-rack |
36 | | -``` |
| 11 | +Experience SQL-compatible structured log management based on ClickHouse. [Learn more ⇗](https://betterstack.com/logs) |
37 | 12 |
|
38 | | -Alternatively, add `gem "logtail-rack"` to your `Gemfile` manually and then run `bundle install`. |
| 13 | +## Documentation |
39 | 14 |
|
40 | | -Then add following configuration into your `config.ru`: |
| 15 | +[Getting started ⇗](https://betterstack.com/docs/logs/ruby-and-rails/#logging-from-rack) |
41 | 16 |
|
42 | | -```ruby |
43 | | -# Initialization of logging middlewares (you don't have to use all) |
44 | | -use Logtail::Integrations::Rack::HTTPContext |
45 | | -use Logtail::Integrations::Rack::HTTPEvents |
46 | | -use Logtail::Integrations::Rack::ErrorEvent |
47 | | -use Logtail::Integrations::Rack::UserContext |
48 | | -use Logtail::Integrations::Rack::SessionContext |
49 | | - |
50 | | -http_io_device = Logtail::LogDevices::HTTP.new("<SOURCE_TOKEN>") |
51 | | -logger = Logtail::Logger.new(http_io_device) |
52 | | -Logtail::Config.instance.logger = logger |
53 | | - |
54 | | -# Here is your application initialization |
55 | | -run ... |
56 | | -``` |
57 | | - |
58 | | -*Don't forget to replace `<SOURCE_TOKEN>` with your actual source token which you can find by going to [Better Stack Logs](https://logs.betterstack.com/dashboard) -> Source -> Edit.* |
| 17 | +## Need help? |
| 18 | +Please let us know at [[email protected]](mailto:[email protected]). We're happy to help! |
59 | 19 |
|
60 | 20 | --- |
61 | 21 |
|
62 | | -# Example project |
63 | | - |
64 | | -To help you get started with using Better Stack in your Rails projects, we have prepared a simple program that showcases the usage of Logtail logger. |
65 | | - |
66 | | -## Download and install the example project |
67 | | - |
68 | | -You can download the [example project](https://github.com/logtail/logtail-ruby-rack/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: |
69 | | - |
70 | | -```bash |
71 | | -bundle install |
72 | | -``` |
73 | | - |
74 | | -This will install all dependencies listed in the `Gemfile.lock` file. |
75 | | - |
76 | | -Then replace `<SOURCE_TOKEN>` in `config.ru` with your actual source token which you can find by going to [Better Stack Logs](https://logs.betterstack.com/dashboard) -> Source -> Edit. |
77 | | - |
78 | | -```ruby |
79 | | -http_io_device = Logtail::LogDevices::HTTP.new("<YOUR_ACTUAL_SOURCE_TOKEN>") |
80 | | -``` |
81 | | - |
82 | | -## Run the example project |
83 | | - |
84 | | -To run the example application, run the following command: |
85 | | - |
86 | | -```bash |
87 | | -rackup |
88 | | -``` |
89 | | - |
90 | | -This will start a local server and you visit [http://127.0.0.1:9292](http://127.0.0.1:9292) in your browser. |
91 | | - |
92 | | -You should see the following output: |
93 | | - |
94 | | -```bash |
95 | | -All done! |
96 | | -Log into your Logtail account to check your logs. |
97 | | -``` |
98 | | - |
99 | | -This will create a total of 4 different logs. You can review these logs in Better Stack. |
100 | | - |
101 | | -You can visit any path on the server to see the request path being logged in context. Visit [/error](http://127.0.0.1:9292) to see an example exception being logged. |
102 | | - |
103 | | -## Explore how example project works |
104 | | - |
105 | | -Learn how to setup Ruby logging by exploring the workings of the [example project](https://github.com/logtail/logtail-ruby-rack/tree/main/example-project) in detail. |
106 | | - |
107 | | ---- |
108 | | - |
109 | | -## Get in touch |
110 | | - |
111 | | -Have any questions? Please explore the Better Stack [documentation](https://betterstack.com/docs/logs/) or contact our [support](https://betterstack.com/help). |
| 22 | +[ISC license](https://github.com/logtail/logtail-ruby-rack/blob/main/LICENSE.md), [example project](https://github.com/logtail/logtail-ruby-rack/tree/main/example-project) |
0 commit comments