README.md in logjam_agent-0.30.0 vs README.md in logjam_agent-0.31.0
- old
+ new
@@ -3,13 +3,18 @@
Client side library for logjam.
Hooks into Rails, collects log lines, performance metrics, error/exception infomation and Rack
environment information and sends this data to [Logjam](https://github.com/skaes/logjam_app).
+Has experimental support for Sinatra.
+
Currently only one mechanism is available for data transport:
ZeroMQ. Support for AMQP has been dropped.
+[](https://travis-ci.org/github/skaes/logjam_agent)
+
+
## Usage
For ZeroMQ, add
```ruby
@@ -108,51 +113,67 @@
end
```
### Generating unique request ids
-The agent generates unique request ids for all request handled. It
-will use [uuid4r](https://github.com/skaes/uuid4r) if this is
-available in the application. Otherwise it will fall back to use the
-standard `SecureRandom` class shipped with Ruby.
+The agent generates unique request ids for all request handled using standard
+`SecureRandom` class shipped with Ruby.
### Generating JSON
The agent will try to use the [Oj](https://github.com/ohler55/oj) to
generate JSON. If this is not available in your application, it will
fall back to the `to_json` method.
-## Troubleshooting
-If the agent experiences problems when sending data, it will log information to a file named
-`logjam_agent_error.log` which you can find under `Rails.root/log`.
-If you set the `RAILS_LOG_TO_STDOUT` environment variable, those logs will be available through `stderr`.
+### Sinatra
-This behavior is customizable via a module level call back method:
+Supports both classic and modular Sinatra applications. Since Sinatra doesn't have built
+in action names like Rails, you'll have to declare them in your handlers, or in a before
+filter. Example:
```ruby
-LogjamAgent.error_handler = lambda {|exception| ... }
+require 'logjam_agent/sinatra'
+
+use LogjamAgent::Sinatra::Middleware
+
+class SinatraTestApp < Sinatra::Base
+ register LogjamAgent::Sinatra
+
+ configure do
+ set :loglevel, :debug
+ setup_logjam_logger
+
+ LogjamAgent.application_name = "myapp"
+ LogjamAgent.add_forwarder(:zmq, :host => "my-logjam-broker")
+ LogjamAgent.parameter_filters << :password
+ end
+
+ before '/index' do
+ action_name "Simple#index"
+ end
+
+ get '/index' do
+ logger.info 'Hello World!'
+ 'Hello World!'
+ end
+end
```
-# License
+The environment name is picked up from either the environment variable `LOGJAM_ENV`, or
+Sinatra's environment setting.
-The MIT License
+Set the environment variable `APP_LOG_TO_STDOUT` if you want to log to `STDOUT`.
+Otherwise, logs will appear in the subdirectory `log` of your application's root.
-Copyright (c) 2013 - 2019 Stefan Kaes
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+## Troubleshooting
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+If the agent experiences problems when sending data, it will log information to a file named
+`logjam_agent_error.log` which you can find under `Rails.root/log`.
+If you set the `RAILS_LOG_TO_STDOUT` environment variable, those logs will be available through `stderr`.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+This behavior is customizable via a module level call back method:
+
+```ruby
+LogjamAgent.error_handler = lambda {|exception| ... }
+```