LogoLogo
OverviewDemos and ResourcesContact
  • What is Engine?
  • Key Concepts
    • Drivers
    • Modules
    • Systems
    • Zones
    • Settings
    • Interfaces
    • Triggers
  • Security
  • Deployment
    • System Architecture
    • Single Sign-On
      • Configuring Engine for SAML2
      • SAML2 with Azure AD
      • SAML2 with ADFS
      • SAML2 with Auth0
      • SAML2 with GSuite
      • OAuth2
  • Integrations
    • Supported Integrations
    • Directory Services
      • Microsoft Office365
    • IoT
      • Device Drivers
      • Node-RED
      • Azure IOT Hub
    • Location Services
      • Locating Users on a Network
      • SVG Map Creation
      • Cisco CMX
      • Cisco Meraki RTLS
      • Desk Sensors
  • Administration
    • Backoffice
      • Systems
      • Devices
      • Drivers
      • Zones
      • Triggers
      • Metrics
      • Users
      • Domains
        • Applications
  • Developer Guide
    • Development Environment
    • Building Drivers
      • Discovery and Metadata
      • State
      • Scheduling Actions
      • Response Tokenisation
      • Device Drivers
      • SSH Drivers
      • Service Drivers
      • Logic Drivers
      • Testing
      • Live Monitoring
      • Logging
      • Security
      • Utilities and Helpers
    • User Interfaces
      • Composer
      • Virtual Systems
      • Widgets
      • Settings.json
  • API
    • Authentication
    • Control
      • Systems
      • Modules
      • Dependencies
      • Zones
      • Websocket
        • Commands
          • bind
          • unbind
          • exec
          • debug
          • ignore
        • Heartbeat
        • Errors
  • Support
    • Service Desk
Powered by GitBook
On this page

Was this helpful?

  1. Developer Guide
  2. Building Drivers

Logging

PreviousLive MonitoringNextSecurity

Last updated 6 years ago

Was this helpful?

The logger is automatically mixed into all driver classes and has the usual logger levels:

  • debug: use debug often for verbose output - not saved to log files by default

  • info: anything you are interested in seeing in the log file

  • warn: something might be wrong, possibly worth investigation.

  • error: something went wrong, definitely worth investigation

  • fatal: something that should never go wrong, went wrong. Requires immediate investigation / resolution

If text being passed to the logger requires some string manipulation or other processor intensive operation, it is worth performing this work in a in case the result is not recorded - this is preferred with debug statements as they are discarded when nobody is watching.

def received(data, resolve, command)
    logger.debug {
        cmd = String.new("Device sent 0x#{byte_to_hex(data)}")
        cmd << " for command #{command[:name]}" if command
        cmd # return the text to be displayed if we are debugging
    }
end

There is also a handy helper method for formatting errors:

begin
    raise 'whoa!'
rescue => e
    logger.print_error e, 'optional additional description of error'
end
block