Module: BWA

Defined in:
lib/bwa/crc.rb,
lib/bwa/proxy.rb,
lib/bwa/client.rb,
lib/bwa/logger.rb,
lib/bwa/server.rb,
lib/bwa/message.rb,
lib/bwa/version.rb,
lib/bwa/discovery.rb,
lib/bwa/messages/error.rb,
lib/bwa/messages/ready.rb,
lib/bwa/messages/status.rb,
lib/bwa/messages/set_time.rb,
lib/bwa/messages/toggle_item.rb,
lib/bwa/messages/configuration.rb,
lib/bwa/messages/filter_cycles.rb,
lib/bwa/messages/nothing_to_send.rb,
lib/bwa/messages/configuration_request.rb,
lib/bwa/messages/control_configuration.rb,
lib/bwa/messages/set_temperature_scale.rb,
lib/bwa/messages/set_target_temperature.rb,
lib/bwa/messages/new_client_clear_to_send.rb,
lib/bwa/messages/control_configuration_request.rb

Defined Under Namespace

Modules: Messages Classes: CRC, Client, Discovery, InvalidMessage, Message, Proxy, Server

Constant Summary collapse

VERSION =
"2.1.7"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject



27
28
29
30
31
32
33
34
35
# File 'lib/bwa/logger.rb', line 27

def logger
  @logger ||= Logger.new($stdout).tap do |log|
    $stdout.sync = true
    log.level = ENV.fetch("LOG_LEVEL", "WARN")
    log.formatter = proc do |severity, _datetime, _progname, msg|
      "#{severity[0..0]}, #{msg2logstr(msg)}\n"
    end
  end
end

.verbosityObject



37
38
39
40
# File 'lib/bwa/logger.rb', line 37

def verbosity
  @verbosity ||= ENV.fetch("LOG_VERBOSITY", "0").to_i
  @verbosity
end

Class Method Details

.msg2logstr(msg) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/bwa/logger.rb', line 42

def msg2logstr(msg)
  case msg
  when ::String
    msg
  when ::Exception
    "#{msg.message} (#{msg.class})\n#{msg.backtrace&.join("\n")}"
  else
    msg.inspect
  end
end

.raw2str(data) ⇒ Object



53
54
55
# File 'lib/bwa/logger.rb', line 53

def raw2str(data)
  data.unpack1("H*").gsub!(/(..)/, "\\1 ").chop!
end