Module: Sonar::Connector::Utils
- Defined in:
- lib/sonar_connector/utils.rb
Class Method Summary collapse
- .disk_logger(filename, base_config) ⇒ Object
-
.du(dir) ⇒ Object
Disk usage utility.
- .stdout_logger(base_config) ⇒ Object
Class Method Details
.disk_logger(filename, base_config) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/sonar_connector/utils.rb', line 28 def disk_logger(filename, base_config) log = Logger.new filename, base_config.log_files_to_keep, base_config.log_file_max_size log.level = base_config.log_level log.formatter = Logger::Formatter.new log.datetime_format = "%Y-%m-%d %H:%M:%S" log end |
.du(dir) ⇒ Object
Disk usage utility. Returns amount of disk space used in a given folder, in bytes.
8 9 10 11 12 13 14 |
# File 'lib/sonar_connector/utils.rb', line 8 def du(dir) raise "#{dir} is not a directory" unless File.directory?(dir) glob = File.join(dir, "**", "*") Dir[glob].map {|f| File.read(f).size rescue nil }.compact.sum end |
.stdout_logger(base_config) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/sonar_connector/utils.rb', line 18 def stdout_logger(base_config) log = Logger.new STDOUT log.level = base_config.log_level log.formatter = Logger::Formatter.new log.datetime_format = "%Y-%m-%d %H:%M:%S" log end |