Module: TestingRecord

Defined in:
lib/testing_record.rb,
lib/testing_record/error.rb,
lib/testing_record/model.rb,
lib/testing_record/logger.rb,
lib/testing_record/version.rb,
lib/testing_record/dsl/builder/filters.rb,
lib/testing_record/dsl/builder/helpers.rb,
lib/testing_record/dsl/builder/settings.rb,
lib/testing_record/dsl/validation/input.rb

Overview

TestingRecord namespace

Defined Under Namespace

Modules: DSL, Error Classes: Logger, Model

Constant Summary collapse

VERSION =
'1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default_primary_keyObject

Returns the value of attribute default_primary_key.



12
13
14
# File 'lib/testing_record.rb', line 12

def default_primary_key
  @default_primary_key
end

Class Method Details

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

Yields:

  • (_self)

Yield Parameters:

  • _self (TestingRecord)

    the object that the method was called on



14
15
16
# File 'lib/testing_record.rb', line 14

def configure
  yield self
end

.log_levelObject

To query what level is being logged

TestingRecord.log_level # => :DEBUG # By default


65
66
67
# File 'lib/testing_record.rb', line 65

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

TestingRecord.log_level = :DEBUG
TestingRecord.log_level = 'DEBUG'
TestingRecord.log_level = 0

To disable all logging

TestingRecord.log_level = :UNKNOWN


59
60
61
# File 'lib/testing_record.rb', line 59

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

.log_path=(logdev) ⇒ Object

This writer method allows you to configure where you want the testingrecord logs to be sent to (Default is $stdout)

Example: TestingRecord.log_path = 'testingrecord.log' would save all log messages to `./testingrecord.log`


47
48
49
# File 'lib/testing_record.rb', line 47

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

.loggerObject

The Testing Record logger object - This is called automatically in several locations and will log messages according to the normal Ruby protocol

This logger object can also be used to manually log messages

To Manually log a message

TestingRecord.logger.info('Information')
TestingRecord.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=`



40
41
42
# File 'lib/testing_record.rb', line 40

def logger
  @logger ||= Logger.create
end