Class: Puma::TCPLogger

### Home Classes Methods

### In Files

- lib/puma/tcp_logger.rb

### Parent

Object

### Methods

- ::new
- #call
- #log

### Files

- Manifest.txt

### Class/Module Index

Quicksearch

- Puma
- Puma::App
- Puma::App::Status
- Puma::Binder
- Puma::CLI
- Puma::Client
- Puma::Cluster
- Puma::Cluster::Worker
- Puma::CommonLogger
- Puma::ConfigDefault
- Puma::Configuration
- Puma::Configuration::ConfigMiddleware
- Puma::ConnectionError
- Puma::Const
- Puma::ControlCLI
- Puma::DSL
- Puma::Delegation
- Puma::Events
- Puma::Events::DefaultFormatter
- Puma::Events::PidFormatter
- Puma::IOBuffer
- Puma::JRubyRestart
- Puma::JavaIOBuffer
- Puma::MiniSSL
- Puma::MiniSSL::Context
- Puma::MiniSSL::SSLError
- Puma::MiniSSL::Server
- Puma::MiniSSL::Socket
- Puma::NullIO
- Puma::Rack
- Puma::Rack::Builder
- Puma::Rack::Options
- Puma::Rack::URLMap
- Puma::Reactor
- Puma::Runner
- Puma::Server
- Puma::Single
- Puma::TCPLogger
- Puma::ThreadPool
- Puma::ThreadPool::AutoTrim
- Puma::ThreadPool::Reaper
- Puma::UnsupportedOption
- Puma::Util
- Puma::Util::HeaderHash
- OpenSSL
- OpenSSL::SSL
- OpenSSL::SSL::SSLServer
- Rack
- Rack::Handler
- Rack::Handler::Puma
- IO
- IO::WaitReadable
- Object
- Process
- String

No matching classes.

# Puma::TCPLogger

### Constants

FORMAT

### Public Class Methods

new(logger, app, quiet=false) click to toggle source

    # File lib/puma/tcp_logger.rb, line 3
    def initialize(logger, app, quiet=false)
      @logger = logger
      @app = app
      @quiet = quiet
    end

### Public Instance Methods

call(env, socket) click to toggle source

    # File lib/puma/tcp_logger.rb, line 17
    def call(env, socket)
      who = env[Const::REMOTE_ADDR]
      log who, "connected" unless @quiet

      env['log'] = lambda { |str| log(who, str) }

      begin
        @app.call env, socket
      rescue Object => e
        log who, "exception: #{e.message} (#{e.class})"
      else
        log who, "disconnected" unless @quiet
      end
    end

log(who, str) click to toggle source

    # File lib/puma/tcp_logger.rb, line 11
    def log(who, str)
      now = Time.now.strftime("%d/%b/%Y %H:%M:%S")

      @logger.puts "#{now} - #{who} - #{str}"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.