Class: Jfrog::Saas::Log::LogConfig
- Inherits:
-
Object
- Object
- Jfrog::Saas::Log::LogConfig
- Includes:
- Singleton
- Defined in:
- lib/jfrog/saas/log/confighandler.rb
Instance Attribute Summary collapse
-
#audit_repo_url ⇒ Object
Returns the value of attribute audit_repo_url.
-
#console_logger ⇒ Object
Returns the value of attribute console_logger.
-
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
-
#log_file_retention_days ⇒ Object
Returns the value of attribute log_file_retention_days.
-
#log_repo_url ⇒ Object
Returns the value of attribute log_repo_url.
-
#log_ship_config ⇒ Object
Returns the value of attribute log_ship_config.
-
#log_types_enabled ⇒ Object
Returns the value of attribute log_types_enabled.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#print_with_utc ⇒ Object
Returns the value of attribute print_with_utc.
-
#solutions_enabled ⇒ Object
Returns the value of attribute solutions_enabled.
-
#target_log_path ⇒ Object
Returns the value of attribute target_log_path.
-
#uri_date_pattern ⇒ Object
Returns the value of attribute uri_date_pattern.
Class Method Summary collapse
- .audit_repo_url ⇒ Object
- .console_logger ⇒ Object
- .debug_mode ⇒ Object
- .log_file_retention_days ⇒ Object
- .log_repo_url ⇒ Object
- .log_ship_config ⇒ Object
- .log_types_enabled ⇒ Object
- .logger ⇒ Object
- .print_with_utc ⇒ Object
- .solutions_enabled ⇒ Object
- .target_log_path ⇒ Object
- .uri_date_pattern ⇒ Object
Instance Method Summary collapse
- #configure(config_file) ⇒ Object
-
#initialize ⇒ LogConfig
constructor
A new instance of LogConfig.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ LogConfig
Returns a new instance of LogConfig.
67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 67 def initialize; end |
Instance Attribute Details
#audit_repo_url ⇒ Object
Returns the value of attribute audit_repo_url.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def audit_repo_url @audit_repo_url end |
#console_logger ⇒ Object
Returns the value of attribute console_logger.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def console_logger @console_logger end |
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def debug_mode @debug_mode end |
#log_file_retention_days ⇒ Object
Returns the value of attribute log_file_retention_days.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def log_file_retention_days @log_file_retention_days end |
#log_repo_url ⇒ Object
Returns the value of attribute log_repo_url.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def log_repo_url @log_repo_url end |
#log_ship_config ⇒ Object
Returns the value of attribute log_ship_config.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def log_ship_config @log_ship_config end |
#log_types_enabled ⇒ Object
Returns the value of attribute log_types_enabled.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def log_types_enabled @log_types_enabled end |
#logger ⇒ Object
Returns the value of attribute logger.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def logger @logger end |
#print_with_utc ⇒ Object
Returns the value of attribute print_with_utc.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def print_with_utc @print_with_utc end |
#solutions_enabled ⇒ Object
Returns the value of attribute solutions_enabled.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def solutions_enabled @solutions_enabled end |
#target_log_path ⇒ Object
Returns the value of attribute target_log_path.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def target_log_path @target_log_path end |
#uri_date_pattern ⇒ Object
Returns the value of attribute uri_date_pattern.
65 66 67 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 65 def uri_date_pattern @uri_date_pattern end |
Class Method Details
.audit_repo_url ⇒ Object
41 42 43 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 41 def self.audit_repo_url audit_repo_url end |
.console_logger ⇒ Object
21 22 23 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 21 def self.console_logger console_logger end |
.debug_mode ⇒ Object
49 50 51 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 49 def self.debug_mode debug_mode end |
.log_file_retention_days ⇒ Object
61 62 63 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 61 def self.log_file_retention_days log_file_retention_days end |
.log_repo_url ⇒ Object
45 46 47 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 45 def self.log_repo_url log_repo_url end |
.log_ship_config ⇒ Object
25 26 27 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 25 def self.log_ship_config log_ship_config end |
.log_types_enabled ⇒ Object
33 34 35 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 33 def self.log_types_enabled log_types_enabled end |
.logger ⇒ Object
17 18 19 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 17 def self.logger logger end |
.print_with_utc ⇒ Object
57 58 59 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 57 def self.print_with_utc print_with_utc end |
.solutions_enabled ⇒ Object
29 30 31 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 29 def self.solutions_enabled solutions_enabled end |
.target_log_path ⇒ Object
53 54 55 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 53 def self.target_log_path target_log_path end |
.uri_date_pattern ⇒ Object
37 38 39 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 37 def self.uri_date_pattern uri_date_pattern end |
Instance Method Details
#configure(config_file) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 69 def configure(config_file) config = YAML.load_file(config_file) self.target_log_path = (config['log']['target_log_path']).to_s.strip log_file = "#{target_log_path}/jfrog-saas-collector.log" FileUtils.mkdir_p(target_log_path) unless File.directory? target_log_path FileUtils.touch(log_file) unless File.exist? log_file self.logger = Logger.new(log_file, 'weekly') self.console_logger = Logger.new($stdout) console_logger.formatter = logger.formatter = proc do |severity, datetime, progname, msg| formatted_date = datetime.strftime('%Y-%m-%d %H:%M:%S') "[ #{formatted_date}, p_id=##{Process.pid}, t_id=##{Thread.current.object_id}, #{severity.ljust(5)}] -- #{msg} \n" end self.log_ship_config = (config['log']['log_ship_config']) self.solutions_enabled = config['log']['solutions_enabled'].map(&:strip) self.log_types_enabled = config['log']['log_types_enabled'].map(&:strip) self.uri_date_pattern = (config['log']['uri_date_pattern']).to_s self.audit_repo_url = (config['log']['audit_repo']).to_s.strip self.log_repo_url = (config['log']['log_repo']).to_s.strip self.debug_mode = (config['log']['debug_mode']) self.print_with_utc = (config['log']['print_with_utc']) self.log_file_retention_days = if (config['log']['log_file_retention_days']).to_i.positive? (config['log']['log_file_retention_days']).to_i else 7 end end |
#to_s ⇒ Object
98 99 100 |
# File 'lib/jfrog/saas/log/confighandler.rb', line 98 def to_s "Object_id :#{object_id}, solutions_enabled :#{solutions_enabled}, log_types_enabled:#{log_types_enabled}, uri_date_pattern: #{uri_date_pattern}" end |