Class: Onlylogs::Configuration
- Inherits:
-
Object
- Object
- Onlylogs::Configuration
- Defined in:
- lib/onlylogs/configuration.rb
Constant Summary collapse
- DEFAULT_SEARCH_TIMEOUT =
Seconds a viewer search may run before it is stopped. Bounded by default: a search holds a CPU for as long as it runs, and an unbounded one over a multi-GB file can starve everything else the host is doing. Generous enough for a full scan of a large file - set it to nil to remove the ceiling entirely.
120
Instance Attribute Summary collapse
-
#basic_auth_password ⇒ Object
Returns the value of attribute basic_auth_password.
-
#basic_auth_user ⇒ Object
Returns the value of attribute basic_auth_user.
-
#default_log_file_path ⇒ Object
Returns the value of attribute default_log_file_path.
-
#disable_basic_authentication ⇒ Object
Returns the value of attribute disable_basic_authentication.
-
#editor ⇒ Object
Returns the value of attribute editor.
-
#log_file_patterns ⇒ Object
Returns the value of attribute log_file_patterns.
-
#max_line_matches ⇒ Object
Returns the value of attribute max_line_matches.
-
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
-
#ripgrep_enabled ⇒ Object
Returns the value of attribute ripgrep_enabled.
-
#search_timeout ⇒ Object
Returns the value of attribute search_timeout.
Instance Method Summary collapse
- #configure {|_self| ... } ⇒ Object
- #default_basic_auth_password ⇒ Object
- #default_basic_auth_user ⇒ Object
- #default_editor ⇒ Object
- #default_log_file_path_value ⇒ Object
- #default_log_file_patterns ⇒ Object
- #default_ripgrep_enabled ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/onlylogs/configuration.rb', line 16 def initialize @log_file_patterns = default_log_file_patterns @default_log_file_path = default_log_file_path_value @basic_auth_user = default_basic_auth_user @basic_auth_password = default_basic_auth_password @parent_controller = nil @disable_basic_authentication = false @ripgrep_enabled = default_ripgrep_enabled @editor = nil @max_line_matches = 100000 @search_timeout = DEFAULT_SEARCH_TIMEOUT end |
Instance Attribute Details
#basic_auth_password ⇒ Object
Returns the value of attribute basic_auth_password.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def basic_auth_password @basic_auth_password end |
#basic_auth_user ⇒ Object
Returns the value of attribute basic_auth_user.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def basic_auth_user @basic_auth_user end |
#default_log_file_path ⇒ Object
Returns the value of attribute default_log_file_path.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def default_log_file_path @default_log_file_path end |
#disable_basic_authentication ⇒ Object
Returns the value of attribute disable_basic_authentication.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def disable_basic_authentication @disable_basic_authentication end |
#editor ⇒ Object
Returns the value of attribute editor.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def editor @editor end |
#log_file_patterns ⇒ Object
Returns the value of attribute log_file_patterns.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def log_file_patterns @log_file_patterns end |
#max_line_matches ⇒ Object
Returns the value of attribute max_line_matches.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def max_line_matches @max_line_matches end |
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def parent_controller @parent_controller end |
#ripgrep_enabled ⇒ Object
Returns the value of attribute ripgrep_enabled.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def ripgrep_enabled @ripgrep_enabled end |
#search_timeout ⇒ Object
Returns the value of attribute search_timeout.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def search_timeout @search_timeout end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
29 30 31 |
# File 'lib/onlylogs/configuration.rb', line 29 def configure yield self end |
#default_basic_auth_password ⇒ Object
70 71 72 |
# File 'lib/onlylogs/configuration.rb', line 70 def default_basic_auth_password ENV["ONLYLOGS_BASIC_AUTH_PASSWORD"] || Rails.application.credentials.dig(:onlylogs, :basic_auth_password) end |
#default_basic_auth_user ⇒ Object
66 67 68 |
# File 'lib/onlylogs/configuration.rb', line 66 def default_basic_auth_user ENV["ONLYLOGS_BASIC_AUTH_USER"] || Rails.application.credentials.dig(:onlylogs, :basic_auth_user) end |
#default_editor ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/onlylogs/configuration.rb', line 33 def default_editor if (credentials_editor = Rails.application.credentials.dig(:onlylogs, :editor)) return credentials_editor end # 2. Check environment variables (ONLYLOGS_EDITOR > RAILS_EDITOR > EDITOR) if ENV["ONLYLOGS_EDITOR"] return ENV["ONLYLOGS_EDITOR"].to_sym end if ENV["RAILS_EDITOR"] return ENV["RAILS_EDITOR"].to_sym end if ENV["EDITOR"] return ENV["EDITOR"].to_sym end # 3. Default fallback :vscode end |
#default_log_file_path_value ⇒ Object
62 63 64 |
# File 'lib/onlylogs/configuration.rb', line 62 def default_log_file_path_value Rails.root.join("log/#{Rails.env}.log").to_s end |
#default_log_file_patterns ⇒ Object
55 56 57 58 59 60 |
# File 'lib/onlylogs/configuration.rb', line 55 def default_log_file_patterns # Default to environment-specific log files (without rotation suffixes) [ Rails.root.join("log/#{Rails.env}.log") ] end |
#default_ripgrep_enabled ⇒ Object
74 75 76 |
# File 'lib/onlylogs/configuration.rb', line 74 def default_ripgrep_enabled system("which rg > /dev/null 2>&1") end |