Module: SSLkeylog::Logging

Defined in:
lib/sslkeylog/logging.rb

Overview

This module configures logging used by SSL tracing

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerLogger

The global logger used by SSL tracers

Must be set to an object that implements the interface provided by the standard Ruby Logger library.

Returns:

  • (Logger)


13
14
15
# File 'lib/sslkeylog/logging.rb', line 13

def logger
  @logger
end

Class Method Details

.default_formatterProc

Returns a default Logger formatter for NSS Key Log messages

This formatter simply echoes any message without adding additional data such as timestamp, severity, etc.

Returns:

  • (Proc)


22
23
24
25
26
# File 'lib/sslkeylog/logging.rb', line 22

def self.default_formatter
  Proc.new do |severity, datetime, progname, msg|
    msg
  end
end

.default_loggerLogger

Returns a default Logger for NSS Key Log messages

Returns:

  • (Logger)

    A logger that appends to a file specified by the SSLKEYLOG environment variable.

  • (Logger)

    A logger that writes to $stderr if the SSLKEYLOG environment variable is not set.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/sslkeylog/logging.rb', line 34

def self.default_logger
  if ENV['SSLKEYLOG']
    output = File.open(ENV['SSLKEYLOG'], 'a')
    # Flush output after every write as an external process, such as
    # Wireshark, may be watching this file.
    output.sync = true
  else
    output = $stderr
  end

  logger = Logger.new(output)
  logger.formatter = default_formatter

  logger
end