Sha256: 96d4912bd0987e731c1fd327faa618058361de9c419988fc89ac4966ae990410

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 KB

Contents

# RailsLogParser

This gem helps you to quick analyse your server logs without external monitor servers. Simple applications with a low number of requests cause only a low number of errors. So you can call a cronjob to analyse your logs periodly. If the summary is not empty your server will email you the result automaticly.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'rails_log_parser'
```

And then execute:

    $ bundle install

Or install it yourself as:

    $ gem install rails_log_parser

## Usage

Sets your server log path:

```ruby
RailsLogParser::Parser.log_path = Rails.root.join('log/production.log')
```

Call the rake tasks in cronjobs:

```
LOG_PATH=/srv/rails/log/production.log
0,20,40 * * * * rake rails_log_parser:parse[22]'      # summary of the last 22 minutes
59     23 * * * rake rails_log_parser:parse[22,true]' # summary of the last 22 minutes and save and analyse heuristic
```

Or use it in your code:

```ruby
parser = RailsLogParser::Parser.from_file(log_path)
puts parser.actions.select(&:fatal?).map(&:headline)
```

```ruby
parser = RailsLogParser::Parser.from_file(log_path)
parser.enable_heuristic(File.dirname(log_path)) # path to save heuristic stats
print parser.summary(last_minutes: 22)          # print summary for the last 22 minutes
```

## Changelog

### 0.0.6

* Adding heuristic to rate known exceptions

### 0.0.5

* Removing `URI::InvalidURIError` as known exceptions

### 0.0.4

* Handle stacktrace of fatals too

### 0.0.3

* Adding `URI::InvalidURIError` as known exceptions

### 0.0.2

* Adding `ActionController::InvalidAuthenticityToken` as known exceptions

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Lichtbit/rails_log_parser.


## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_log_parser-0.0.6 README.md