Module: Padrino::Logger::Extensions

Included in:
Padrino::Logger

Constant Summary collapse

SOURCE_LOCATION_REGEXP =
/^(.*?):(\d+?)(?::in `.+?')?$/.freeze

Instance Method Summary

Instance Method Details

#bench(action, began_at, message, level = :debug, color = :yellow) ⇒ Object

Append a to development logger a given action with time.

Examples:

logger.bench 'GET', started_at, '/blog/categories'
# => DEBUG - GET (0.0056s) - /blog/categories

Parameters:

  • action (string) — The action.
  • time (float) — Time duration for the given action.
  • string (message) — The message that you want to log.

#colorize(string, *colors) ⇒ Object

Colorizes a string for colored console output. This is a noop and can be reimplemented to colorize the string as needed.

Parameters:

  • The (string) — string to be colorized.
  • The (Array<Symbol>) — colors to use. Should be applied in the order given.

See Also:

  • ColorizedLogger

#colorize! ⇒ Object

Turns a logger with LoggingExtensions into a logger with colorized output.

Examples:

Padrino.logger = Logger.new($stdout)
Padrino.logger.colorize!
Padrino.logger.debug("Fancy Padrino debug string")

#enable_source_location? ⇒ Boolean

Returns true if :source_location is set to true.

Returns:

  • (Boolean)

#exception(boom, verbosity = :long, level = :error) ⇒ Object

Logs an exception.

Examples:

Padrino.logger.exception e
Padrino.logger.exception(e, :short)

Parameters:

  • exception (Exception) — The exception to log
  • verbosity (Symbol) (defaults to: :long) — :short or :long, default is :long

#format(message, level) ⇒ Object

Formats the log message. This method is a noop and should be implemented by other logger components such as Padrino::Logger.

Parameters:

  • message (String) — The message to format.
  • level (String, Symbol) — The log level, one of :debug, :warn …

#name ⇒ Object

Generate the logging methods for Padrino.logger for each log level.

#push(message = nil, level = nil) ⇒ Object

Appends a message to the log. The methods yield to an optional block and the output of this block will be appended to the message.

Parameters:

  • message (String) (defaults to: nil) — The message that you want write to your stream.
  • level (String) (defaults to: nil) — The level one of :debug, :warn etc. …

#resolve_source_location(message) ⇒ Object

Resolves a filename and line-number from caller.

#stylized_level(level) ⇒ Object

The debug level, with some style added. May be reimplemented.

Examples:

stylized_level(:debug) => DEBUG

Parameters:

  • level (String, Symbol) — The log level.

© 2010–2020 Padrino
Licensed under the MIT License.
https://www.rubydoc.info/github/padrino/padrino-framework/Padrino/Logger/Extensions