-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Example project | ||
|
||
To help you get started with using Better Stack in your Rack projects, we have prepared a simple program that showcases the usage of Logtail logger. | ||
|
||
## Download and install the example project | ||
|
||
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: | ||
|
||
```bash | ||
bundle install | ||
``` | ||
|
||
This will install all dependencies listed in the `Gemfile.lock` file. | ||
|
||
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. | ||
|
||
```ruby | ||
http_io_device = Logtail::LogDevices::HTTP.new("<YOUR_ACTUAL_SOURCE_TOKEN>") | ||
``` | ||
|
||
## Run the example project | ||
|
||
To run the example application, run the following command: | ||
|
||
```bash | ||
rackup | ||
``` | ||
|
||
This will start a local server and you visit [http://127.0.0.1:9292](http://127.0.0.1:9292) in your browser. | ||
|
||
You should see the following output: | ||
|
||
```bash | ||
All done! | ||
Log into your Logtail account to check your logs. | ||
``` | ||
|
||
This will create a total of 4 different logs. You can review these logs in Better Stack. | ||
|
||
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. |