Module: SitePrism

Defined in:
lib/site_prism.rb,
lib/site_prism/dsl.rb,
lib/site_prism/page.rb,
lib/site_prism/error.rb,
lib/site_prism/logger.rb,
lib/site_prism/waiter.rb,
lib/site_prism/section.rb,
lib/site_prism/version.rb,
lib/site_prism/loadable.rb,
lib/site_prism/element_checker.rb,
lib/site_prism/addressable_url_matcher.rb

Defined Under Namespace

Modules: DSL, ElementChecker, Loadable Classes: AddressableUrlMatcher, BlockError, ElementInvisibilityTimeoutError, ElementVisibilityTimeoutError, FailedLoadValidationError, FrozenInTimeError, InvalidElementError, InvalidUrlMatcherError, Logger, MissingBlockError, NoUrlForPageError, NoUrlMatcherForPageError, Page, PageLoadError, Section, SitePrismError, TimeoutError, UnsupportedBlockError, Waiter

Constant Summary collapse

VERSION =
'3.2'

Class Method Summary collapse

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (SitePrism)

    the object that the method was called on



16
17
18
# File 'lib/site_prism.rb', line 16

def configure
  yield self
end

.log_levelObject

To query what level is being logged

SitePrism.log_level
=> :UNKNOWN # By default


63
64
65
# File 'lib/site_prism.rb', line 63

def log_level
  %i[DEBUG INFO WARN ERROR FATAL UNKNOWN][logger.level]
end

.log_level=(value) ⇒ Object

To enable full logging (This uses the Ruby API, so can accept any of a Symbol / String / Integer as an input

SitePrism.log_level = :DEBUG
SitePrism.log_level = 'DEBUG'
SitePrism.log_level = 0

To disable all logging (Done by default)

SitePrism.log_level = :UNKNOWN


56
57
58
# File 'lib/site_prism.rb', line 56

def log_level=(value)
  logger.level = value
end

.log_path=(logdev) ⇒ Object

`Logger#reopen` was added in Ruby 2.3 - Which is now the minimum version for the site_prism gem

This writer method allows you to configure where you want the output of the site_prism logs to go (Default is $stdout)

example: SitePrism.log_path = 'site_prism.log' would save all log messages to `./site_prism.log`



44
45
46
# File 'lib/site_prism.rb', line 44

def log_path=(logdev)
  logger.reopen(logdev)
end

.loggerObject

The SitePrism logger object - This is called automatically in several locations and will log messages according to the normal Ruby protocol To alter (or check), the log level; call .log_level= or .log_level

This logger object can also be used to manually log messages

To Manually log a message

SitePrism.logger.info('Information')
SitePrism.logger.debug('Input debug message')

By default the logger will output all messages to $stdout, but can be altered to log to a file or another IO location by calling `.log_path=`



32
33
34
# File 'lib/site_prism.rb', line 32

def logger
  @logger ||= SitePrism::Logger.new.create
end