Skip to content

Logging

Juanito Fatas edited this page Jun 1, 2022 · 14 revisions

Buildkite::TestCollector uses a custom logger that prints process and thread information in the logs to help with debug:

# UTC Timestamp -------------- Process - Thread - Message
2022-05-23T05:37:06.002995000Z pid=27241 tid=7060 DEBUG: added 12345678-1234-1234-1234-123456781234 to send queue
  • pid: Process.pid
  • tid: Thread.current.object_id

Buildkite::TestCollector uses Ruby’s Logger library and log level defaults to Logger::WARN and logs to $stderr.

Turning on debug mode

If you want to turn on debugging for Buildkite::TestCollector, you can change the log level to Logger::DEBUG by:

  • Set BUILDKITE_ANALYTICS_DEBUG_ENABLED environment variable to any value
  • Set $DEBUG flag to a truthy value
  • Change the log level of Buildkite::TestCollector.logger
    Buildkite::TestCollector.logger.level = ::Logger::DEBUG

Logging to file

Buildkite::TestCollector.logger = Buildkite::TestCollector::Logger.new("log/buildkite-analytics-collector.log")

Additionally, add artifacts_path to your pipeline configuration to make the log available as a Build artifact, learn more about using Buildkite artifacts.

Quieting the Test Environment

To silent Buildkite::TestCollector logging in your test environment, set the log level to ERROR or FATAL:

Buildkite::TestCollector.logger.level = Logger::ERROR

Disabling logs

Simply send the logs to /dev/null:

Buildkite::TestCollector.logger = Buildkite::TestCollector::Logger.new("/dev/null")

Clone this wiki locally