Module: Contrast::Utils::LogUtils

Included in:
Config::Diagnostics::Monitor, Logger::CEFLog, Logger::Log, CEFLogUtils
Defined in:
lib/contrast/utils/log_utils.rb

Overview

Method utility used by Contrast::Logger::log

Constant Summary collapse

DEFAULT_NAME =
'contrast.log'
DEFAULT_LEVEL =
'INFO'
VALID_LEVELS =
::Ougai::Logging::Severity::SEV_LABEL
STDOUT_STR =
'STDOUT'
STDERR_STR =
'STDERR'
PROGNAME =
'Contrast Agent'
DATE_TIME_FORMAT =
'%Y-%m-%dT%H:%M:%S.%L%z'

Instance Method Summary collapse

Instance Method Details

#write_permission?(path) ⇒ Boolean

StringIO is a valid path because it logs directly to a string buffer

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
# File 'lib/contrast/utils/log_utils.rb', line 23

def write_permission? path
  return false if path.nil?
  return true if path.is_a?(StringIO)
  return File.writable?(path) if File.exist?(path)

  dir_name = File.dirname(File.absolute_path(path))
  FileUtils.mkdir_p(dir_name)
  File.writable?(dir_name)
end