Class: LogConfiguration
- Inherits:
 - 
      Object
      
        
- Object
 - LogConfiguration
 
 
- Defined in:
 - lib/AuthenticationSDK/logging/log_configuration.rb
 
Instance Attribute Summary collapse
- 
  
    
      #enableLog  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Setter/Getter.
 - 
  
    
      #enableMasking  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute enableMasking.
 - 
  
    
      #logDirectory  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute logDirectory.
 - 
  
    
      #logFilename  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute logFilename.
 - 
  
    
      #loggingLevel  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute loggingLevel.
 - 
  
    
      #maxLogFiles  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute maxLogFiles.
 - 
  
    
      #maxLogSize  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute maxLogSize.
 
Instance Method Summary collapse
- 
  
    
      #initialize(log_config)  ⇒ LogConfiguration 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of LogConfiguration.
 - #validate(log_message) ⇒ Object
 
Constructor Details
#initialize(log_config) ⇒ LogConfiguration
Returns a new instance of LogConfiguration.
      14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70  | 
    
      # File 'lib/AuthenticationSDK/logging/log_configuration.rb', line 14 def initialize(log_config) @enableLog = log_config['enableLog'] @loggingLevel = log_config['loggingLevel'] @logDirectory = log_config['logDirectory'] @logFilename = log_config['logFilename'] @maxLogSize = log_config['maxLogSize'] @maxLogFiles = log_config['maxLogFiles'] @enableMasking = log_config['enableMasking'] def validate() if @enableLog == "true" @enableLog = true elsif @enableLog == true @enableLog = true else @enableLog = false end if @enableLog if !Constants::LOG_LEVELS.include? @loggingLevel @loggingLevel = Constants::DEFAULT_LOG_LEVEL += Constants::WARNING_PREFIX + Constants::INVALID_LOG_LEVEL + @loggingLevel end if @logDirectory.to_s.empty? # || !Dir.exist?(@logDirectory) @logDirectory = Constants::DEFAULT_LOG_DIRECTORY unless Dir.exist?(@logDirectory) Dir.mkdir(Constants::DEFAULT_LOG_DIRECTORY) end += Constants::WARNING_PREFIX + Constants::INVALID_LOG_DIRECTORY + File.(@logDirectory) end if @logFilename.to_s.empty? @logFilename = Constants::DEFAULT_LOGFILE_NAME elsif !@logFilename.instance_of? String @logFilename = @logFilename.to_s end if @maxLogSize.nil? || @maxLogSize.to_s.empty? @maxLogSize = Constants::DEFAULT_LOG_SIZE += Constants::WARNING_PREFIX + Constants::INVALID_MAX_LOG_SIZE + @maxLogSize elsif !@maxLogSize.instance_of? Integer @maxLogSize = @maxLogSize.to_i end if @maxLogFiles.nil? || @maxLogFiles.to_s.empty? @maxLogFiles = Constants::DEFAULT_MAX_LOG_FILES += Constants::WARNING_PREFIX + Constants::INVALID_MAX_LOG_FILES + @maxLogFiles elsif !@maxLogFiles.instance_of? Integer @maxLogFiles = @maxLogFiles.to_i end if @enableMasking == "true" @enableMasking = true elsif @enableMasking == true @enableMasking = true else @enableMasking = false end end return end end  | 
  
Instance Attribute Details
#enableLog ⇒ Object
Setter/Getter
      6 7 8  | 
    
      # File 'lib/AuthenticationSDK/logging/log_configuration.rb', line 6 def enableLog @enableLog end  | 
  
#enableMasking ⇒ Object
Returns the value of attribute enableMasking.
      12 13 14  | 
    
      # File 'lib/AuthenticationSDK/logging/log_configuration.rb', line 12 def enableMasking @enableMasking end  | 
  
#logDirectory ⇒ Object
Returns the value of attribute logDirectory.
      8 9 10  | 
    
      # File 'lib/AuthenticationSDK/logging/log_configuration.rb', line 8 def logDirectory @logDirectory end  | 
  
#logFilename ⇒ Object
Returns the value of attribute logFilename.
      9 10 11  | 
    
      # File 'lib/AuthenticationSDK/logging/log_configuration.rb', line 9 def logFilename @logFilename end  | 
  
#loggingLevel ⇒ Object
Returns the value of attribute loggingLevel.
      7 8 9  | 
    
      # File 'lib/AuthenticationSDK/logging/log_configuration.rb', line 7 def loggingLevel @loggingLevel end  | 
  
#maxLogFiles ⇒ Object
Returns the value of attribute maxLogFiles.
      11 12 13  | 
    
      # File 'lib/AuthenticationSDK/logging/log_configuration.rb', line 11 def maxLogFiles @maxLogFiles end  | 
  
#maxLogSize ⇒ Object
Returns the value of attribute maxLogSize.
      10 11 12  | 
    
      # File 'lib/AuthenticationSDK/logging/log_configuration.rb', line 10 def maxLogSize @maxLogSize end  | 
  
Instance Method Details
#validate(log_message) ⇒ Object
      23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69  | 
    
      # File 'lib/AuthenticationSDK/logging/log_configuration.rb', line 23 def validate() if @enableLog == "true" @enableLog = true elsif @enableLog == true @enableLog = true else @enableLog = false end if @enableLog if !Constants::LOG_LEVELS.include? @loggingLevel @loggingLevel = Constants::DEFAULT_LOG_LEVEL += Constants::WARNING_PREFIX + Constants::INVALID_LOG_LEVEL + @loggingLevel end if @logDirectory.to_s.empty? # || !Dir.exist?(@logDirectory) @logDirectory = Constants::DEFAULT_LOG_DIRECTORY unless Dir.exist?(@logDirectory) Dir.mkdir(Constants::DEFAULT_LOG_DIRECTORY) end += Constants::WARNING_PREFIX + Constants::INVALID_LOG_DIRECTORY + File.(@logDirectory) end if @logFilename.to_s.empty? @logFilename = Constants::DEFAULT_LOGFILE_NAME elsif !@logFilename.instance_of? String @logFilename = @logFilename.to_s end if @maxLogSize.nil? || @maxLogSize.to_s.empty? @maxLogSize = Constants::DEFAULT_LOG_SIZE += Constants::WARNING_PREFIX + Constants::INVALID_MAX_LOG_SIZE + @maxLogSize elsif !@maxLogSize.instance_of? Integer @maxLogSize = @maxLogSize.to_i end if @maxLogFiles.nil? || @maxLogFiles.to_s.empty? @maxLogFiles = Constants::DEFAULT_MAX_LOG_FILES += Constants::WARNING_PREFIX + Constants::INVALID_MAX_LOG_FILES + @maxLogFiles elsif !@maxLogFiles.instance_of? Integer @maxLogFiles = @maxLogFiles.to_i end if @enableMasking == "true" @enableMasking = true elsif @enableMasking == true @enableMasking = true else @enableMasking = false end end return end  |