Socket
Book a DemoInstallSign in
Socket

api_hit_logger

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api_hit_logger

0.2.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

ApiHitLogger

Rack middleware to log all API request details into a rotating CSV log file.

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add api_hit_logger

If bundler is not being used to manage dependencies, install the gem by executing:

gem install api_hit_logger

Usage

To enable request logging with ApiHitLogger, simply add the middleware to your Rails or Rack-based application:

  • Require the gem In your config/application.rb or equivalent setup file: require 'api_hit_logger'

  • Add the middleware

For Rails: config/application.rb config.middleware.use ApiHitLogger::Middleware

For Rack apps, update your config.ru: use ApiHitLogger::Middleware

Once set up, all incoming HTTP requests will be logged to a CSV file in the log/ directory, with a separate file generated for each day.

No additional configuration is required for basic usage.

Log File Location The logs are written to: log/api_hit_logs_YYYY-MM-DD.csv

Each day's requests are stored in their own CSV/JSON file.

Configuration

To customize how API hits are logged, create a file at:

With the following content:

ApiHitLogger.configure do |config|
  # Format options: :csv, :json (default: :csv)
  config.log_format = :csv
end

If no initializer is present, default settings will be used.

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/chaitanyag1-c/api_hit_logger. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/chaitanyag1-c/api_hit_logger/blob/master/CODE_OF_CONDUCT.md).

## License

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

## Code of Conduct

Everyone interacting in the ApiHitLogger project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/chaitanyag1-c/api_hit_logger/blob/master/CODE_OF_CONDUCT.md).

FAQs

Package last updated on 26 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.