Module: BlackStack::Logger
- Defined in:
- lib/baselogger.rb
Constant Summary collapse
- DEFAULT_MIN_SIZE =
10*1024*1024
- DEFAULT_MAX_SIZE =
20*1024*1024
- DEFAULT_SHOW_NESTING_LEVEL =
false
- DEFAULT_SHOW_NESTING_CALLER =
false
- DEFAULT_COLORIZE =
true
- DEFAULT_NESTING_ASSERTION =
true
- @@min_size =
DEFAULT_MIN_SIZE
- @@max_size =
DEFAULT_MAX_SIZE
- @@show_nesting_level =
DEFAULT_SHOW_NESTING_LEVEL
- @@show_nesting_caller =
DEFAULT_SHOW_NESTING_CALLER
- @@colorize =
DEFAULT_COLORIZE
- @@nesting_assertion =
DEFAULT_NESTING_ASSERTION
Class Method Summary collapse
- .colorize ⇒ Object
- .max_size ⇒ Object
- .min_size ⇒ Object
- .nesting_assertion ⇒ Object
- .set(min_size: DEFAULT_MIN_SIZE, max_size: DEFAULT_MAX_SIZE, show_nesting_level: DEFAULT_SHOW_NESTING_LEVEL, show_nesting_caller: DEFAULT_SHOW_NESTING_CALLER, colorize: DEFAULT_COLORIZE, nesting_assertion: DEFAULT_NESTING_ASSERTION) ⇒ Object
- .show_nesting_caller ⇒ Object
- .show_nesting_level ⇒ Object
Class Method Details
.colorize ⇒ Object
82 83 84 |
# File 'lib/baselogger.rb', line 82 def self.colorize() @@colorize end |
.max_size ⇒ Object
70 71 72 |
# File 'lib/baselogger.rb', line 70 def self.max_size() @@max_size end |
.min_size ⇒ Object
66 67 68 |
# File 'lib/baselogger.rb', line 66 def self.min_size() @@min_size end |
.nesting_assertion ⇒ Object
86 87 88 |
# File 'lib/baselogger.rb', line 86 def self.nesting_assertion() @@nesting_assertion end |
.set(min_size: DEFAULT_MIN_SIZE, max_size: DEFAULT_MAX_SIZE, show_nesting_level: DEFAULT_SHOW_NESTING_LEVEL, show_nesting_caller: DEFAULT_SHOW_NESTING_CALLER, colorize: DEFAULT_COLORIZE, nesting_assertion: DEFAULT_NESTING_ASSERTION) ⇒ Object
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 |
# File 'lib/baselogger.rb', line 18 def self.set( min_size: DEFAULT_MIN_SIZE, max_size: DEFAULT_MAX_SIZE, show_nesting_level: DEFAULT_SHOW_NESTING_LEVEL, show_nesting_caller: DEFAULT_SHOW_NESTING_CALLER, colorize: DEFAULT_COLORIZE, nesting_assertion: DEFAULT_NESTING_ASSERTION ) err = [] # min_size must be a positive integer err << "min_byes must be apositive integer." if !min_size.is_a?(Integer) || min_size.to_i < 0 err << "max_byes must be apositive integer." if !max_size.is_a?(Integer) || max_size.to_i < 0 err << "min_byes must be lower than max_size." if min_size.is_a?(Integer) && max_size.is_a?(Integer) && !(min_size < max_size) err << "show_nesting_level must be a boolean." if ![true, false].include?(show_nesting_level) err << "show_nesting_caller must be a boolean." if ![true, false].include?(show_nesting_caller) err << "colorize must be a boolean." if ![true, false].include?(colorize) err << "nesting_assertion must be a boolean." if ![true, false].include?(nesting_assertion) @@min_size = min_size @@max_size = max_size @@show_nesting_level = show_nesting_level @@show_nesting_caller = show_nesting_caller @@colorize = colorize @@nesting_assertion = nesting_assertion if !colorize # overwrite the instance methods green, red, blue and yellow of the class String from inside the constructor of another class, to make them non-effect. String.class_eval do define_method(:green) do self end define_method(:red) do self end define_method(:blue) do self end define_method(:yellow) do self end end end end |
.show_nesting_caller ⇒ Object
78 79 80 |
# File 'lib/baselogger.rb', line 78 def self.show_nesting_caller() @@show_nesting_caller end |
.show_nesting_level ⇒ Object
74 75 76 |
# File 'lib/baselogger.rb', line 74 def self.show_nesting_level() @@show_nesting_level end |