Module: Loba::Internal::Platform Private

Defined in:
lib/loba/internal/platform.rb,
lib/loba/internal/platform/formatter.rb,
lib/loba/internal/platform/within_rails.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Internal module for managing output and logging across Rails and non-Rails applications

Defined Under Namespace

Modules: WithinRails Classes: Formatter

Class Method Summary collapse

Class Method Details

.writer(settings:) ⇒ lambda {|message| ...}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

To avoid doubled output, if a non-Rails logger is to be logged to and logdev is set to $stdout, then output will be suppressed (i.e., settings.out is false). Doubled output can still occur; in that case, explicitly use out: false.

Provides mechanism for appropriate console output and logging.

Parameters:

Returns:

  • (lambda {|message| ...})

    procedure for presenting output. Takes one argument, message (String), for the output to be written



18
19
20
21
22
23
24
# File 'lib/loba/internal/platform.rb', line 18

def writer(settings:)
  lambda do |message|
    puts(message) if settings.out?

    settings.logger.debug { message } if settings.log?
  end
end