Class: GlobalLogger
- Inherits:
-
Object
- Object
- GlobalLogger
- Includes:
- Singleton
- Defined in:
- lib/crtu/utils/logger.rb
Instance Attribute Summary collapse
-
#global_console_logger ⇒ Object
readonly
Returns the value of attribute global_console_logger.
-
#global_file_logger ⇒ Object
readonly
Returns the value of attribute global_file_logger.
-
#global_mix_logger ⇒ Object
readonly
Returns the value of attribute global_mix_logger.
Instance Method Summary collapse
-
#initialize ⇒ GlobalLogger
constructor
A new instance of GlobalLogger.
Constructor Details
#initialize ⇒ GlobalLogger
Returns a new instance of GlobalLogger.
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 |
# File 'lib/crtu/utils/logger.rb', line 19 def initialize # Chech if folder exists # that way it creates the logs folder beforehand dirname = File.dirname(GLOBAL_LOGGER_FOLDER) unless File.directory?(dirname) FileUtils.mkdir_p(GLOBAL_LOGGER_FOLDER) end @global_console_logger= Log4r::Logger.new('GlobalLoggerConsole') @global_file_logger = Log4r::Logger.new('GlobalLoggerFile') @global_mix_logger = Log4r::Logger.new('GlobalLoggerConsoleAndFile') pf = PatternFormatter.new(:pattern => "[%l] @ %d : %M") so = StdoutOutputter.new('console', :formatter => pf) @global_console_logger.outputters << so @global_console_logger.level = DEBUG fo = RollingFileOutputter .new('f1', filename: GLOBAL_LOGGER_LOG_FILE, trunc: false, :formatter => pf, maxtime: SECONDS_IN_DAY ) @global_file_logger.outputters << fo @global_file_logger.level = DEBUG @global_mix_logger.outputters << so @global_mix_logger.outputters << fo @global_mix_logger.level = DEBUG end |
Instance Attribute Details
#global_console_logger ⇒ Object (readonly)
Returns the value of attribute global_console_logger.
15 16 17 |
# File 'lib/crtu/utils/logger.rb', line 15 def global_console_logger @global_console_logger end |
#global_file_logger ⇒ Object (readonly)
Returns the value of attribute global_file_logger.
16 17 18 |
# File 'lib/crtu/utils/logger.rb', line 16 def global_file_logger @global_file_logger end |
#global_mix_logger ⇒ Object (readonly)
Returns the value of attribute global_mix_logger.
17 18 19 |
# File 'lib/crtu/utils/logger.rb', line 17 def global_mix_logger @global_mix_logger end |