ElasticsearchEnvConfig
Provides redis client configuration based on environment variables:
ELASTICSEARCH_HOSTS
- comma-separated list of standard elasticsearch hosts understood by the elasticsearch-transport gem.ELASTICSEARCH_INDEX
- index to log into, sans date pattern (required)ELASTICSEARCH_USER
- username for authenticating against all hosts (required if ELASTICSEARCH_PASSWORD
is given)ELASTICSEARCH_PASSWORD
- password for authenticating against all hosts (required if ELASTICSEARCH_USER
is given)ELASTICSEARCH_DATE_PATTERN
- time format used to generate the full index nameELASTICSEARCH_HOST
- name of this host to appear in log messagesELASTICSEARCH_APPLICATION
- name of this application to appear in log messages
Installation
Add this line to your application's Gemfile:
gem 'elasticsearch_env_config'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install elasticsearch_env_config
Usage
require "redis"
require "elasticsearch"
require "semantic_logger"
SemanticLogger.add_appender(appender: :elasticsearch, **(ElasticSearchEnvConfig.new.to_h))
Development
After checking out the repo, run docker-compose build && docker-compose run test
to run the tests.
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 tags, and push the .gem
file to rubygems.org.
For development without docker-compose, you can skip examples that connect to elasticsearch with:
ELASTICSEARCH_HOSTS=fake bundle exec rspec -fd --tag ~connect spec
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/webnifico/elasticsearch_env_config.
License
The gem is available as open source under the terms of the MIT License.