Class: Loog::Ellipsized
- Inherits:
-
Object
- Object
- Loog::Ellipsized
- Defined in:
- lib/loog/ellipsized.rb
Overview
Log decorator that makes all lines ellipsized in the middle.
require 'loog' require 'loog/ellipsized' tee = Loog::Ellipsized.new(Loog::VERBOSE, 10) tee.info('Hello, world!')
Only a part of the message is printed.
- Author
Yegor Bugayenko ([email protected])
- Copyright
Copyright (c) 2018-2026 Yegor Bugayenko
- License
MIT
Instance Method Summary collapse
- #debug(msg) ⇒ Object
- #debug? ⇒ Boolean
- #error(msg) ⇒ Object
- #error? ⇒ Boolean
- #info(msg) ⇒ Object
- #info? ⇒ Boolean
-
#initialize(log, width = 100) ⇒ Ellipsized
constructor
Makes an instance.
- #warn(msg) ⇒ Object
- #warn? ⇒ Boolean
Constructor Details
#initialize(log, width = 100) ⇒ Ellipsized
Makes an instance.
23 24 25 26 |
# File 'lib/loog/ellipsized.rb', line 23 def initialize(log, width = 100) @log = log @width = width end |
Instance Method Details
#debug(msg) ⇒ Object
28 29 30 |
# File 'lib/loog/ellipsized.rb', line 28 def debug(msg) @log.debug(squeezed(msg).ellipsized(@width)) end |
#debug? ⇒ Boolean
32 33 34 |
# File 'lib/loog/ellipsized.rb', line 32 def debug? @log.debug? end |
#error(msg) ⇒ Object
52 53 54 |
# File 'lib/loog/ellipsized.rb', line 52 def error(msg) @log.error(squeezed(msg).ellipsized(@width)) end |
#error? ⇒ Boolean
56 57 58 |
# File 'lib/loog/ellipsized.rb', line 56 def error? @log.error? end |
#info(msg) ⇒ Object
36 37 38 |
# File 'lib/loog/ellipsized.rb', line 36 def info(msg) @log.info(squeezed(msg).ellipsized(@width)) end |
#info? ⇒ Boolean
40 41 42 |
# File 'lib/loog/ellipsized.rb', line 40 def info? @log.info? end |
#warn(msg) ⇒ Object
44 45 46 |
# File 'lib/loog/ellipsized.rb', line 44 def warn(msg) @log.warn(squeezed(msg).ellipsized(@width)) end |
#warn? ⇒ Boolean
48 49 50 |
# File 'lib/loog/ellipsized.rb', line 48 def warn? @log.warn? end |