- README

- Top Level Namespace
- Adler32
- ArgumentError
- Array
- Atomic
- Base64
  - Error
- Benchmark
  - BM
    - Job
    - Tms
  - IPS
    - Entry
    - Job
- BigFloat
- BigInt
- BigRational
- BitArray
- Bool
- Box
- Bytes
- Channel
  - Buffered
  - ClosedError
  - ReceiveAction
  - SelectAction
  - SendAction
  - Unbuffered
- Char
  - Reader
- Class
- Colorize
  - Object
  - ObjectExtensions
- Comparable
- Complex
- Concurrent
  - CanceledError
- CRC32
- Crypto
  - Bcrypt
    - Error
    - Password
  - Blowfish
  - Subtle
- CSV
  - Builder
    - Row
  - Error
  - Lexer
  - MalformedCSVError
  - Parser
  - Row
  - Token
    - Kind
- Debug
  - DWARF
    - Abbrev
      - Attribute
    - AT
    - FORM
    - Info
      - Value
    - LineNumbers
      - Register
      - Row
      - Sequence
    - LNE
    - LNS
    - Strings
    - TAG
  - ELF
    - Endianness
    - Error
    - Ident
    - Klass
    - Machine
    - OSABI
    - SectionHeader
      - Flags
      - Type
    - Type
- Deque
- Digest
  - Base
  - MD5
  - SHA1
- Dir
- DivisionByZero
- DL
- ECR
- Enum
- Enumerable
  - EmptyError
- ENV
- Errno
- Exception
- Fiber
- File
  - Stat
- FileUtils
- Flate
  - Error
  - Reader
  - Strategy
  - Writer
- Float
  - Primitive
- Float32
- Float64
- GC
  - Stats
- Gzip
  - Error
  - Header
  - Reader
  - Writer
- Hash
- HTML
- HTTP
  - Client
    - BodyType
    - Response
  - CompressHandler
  - ComputedContentTypeHeader
  - Cookie
  - Cookies
  - ErrorHandler
  - FormData
    - Builder
    - Error
    - FileMetadata
    - Parser
    - Part
  - Handler
    - Proc
  - Headers
  - LogHandler
  - Multipart
    - Builder
    - Error
    - Parser
  - Params
    - Builder
  - Request
  - Server
    - Context
    - RequestProcessor
    - Response
  - StaticFileHandler
    - DirectoryListing
  - WebSocket
  - WebSocketHandler
- Indexable
- IndexError
- INI
- Int
  - Primitive
  - Signed
  - Unsigned
- Int16
- Int32
- Int64
- Int8
- InvalidByteSequenceError
- IO
  - Buffered
  - ByteFormat
    - BigEndian
    - LittleEndian
    - NetworkEndian
    - SystemEndian
  - Delimited
  - EncodingOptions
  - EOFError
  - Error
  - FileDescriptor
  - Hexdump
  - Memory
  - MultiWriter
  - Seek
  - Sized
  - Timeout
- IPSocket
- Iterable
- Iterator
  - IteratorWrapper
  - Stop
- JSON
  - Any
  - Builder
    - ArrayState
    - DocumentEndState
    - DocumentStartState
    - ObjectState
    - StartState
    - State
  - Error
  - Lexer
  - ParseException
  - Parser
  - PullParser
  - Token
  - Type
- KeyError
- Levenshtein
  - Finder
- LLVM
  - ABI
    - AArch64
    - ArgKind
    - ArgType
    - ARM
    - FunctionType
    - X86
    - X86_64
      - RegClass
  - AtomicOrdering
  - AtomicRMWBinOp
  - Attribute
  - AttributeIndex
  - BasicBlock
  - BasicBlockCollection
  - Builder
  - CallConvention
  - CodeGenFileType
  - CodeGenOptLevel
  - CodeModel
  - Context
  - DIBuilder
  - DIFlags
  - DwarfTag
  - DwarfTypeEncoding
  - Function
  - FunctionCollection
  - FunctionPassManager
    - Runner
  - GenericValue
  - GlobalCollection
  - InstructionCollection
  - IntPredicate
  - JITCompiler
  - Linkage
  - MemoryBuffer
  - Module
  - ModuleFlag
  - ModulePassManager
  - ParameterCollection
  - PassManagerBuilder
  - PassRegistry
  - PhiTable
  - RealPredicate
  - RelocMode
  - Target
  - TargetData
  - TargetMachine
  - Type
    - Kind
  - Value
    - Kind
  - ValueMethods
  - VerifierFailureAction
- Logger
  - Formatter
  - Severity
- Markdown
  - HTMLRenderer
  - Parser
    - PrefixHeader
    - UnorderedList
  - Renderer
- Math
- Mutex
- NamedTuple
- Nil
- Number
  - Primitive
- OAuth
  - AccessToken
  - Consumer
  - Error
  - RequestToken
- OAuth2
  - AccessToken
    - Bearer
    - Mac
  - Client
  - Error
  - Session
- Object
- OpenSSL
  - Digest
    - Error
    - UnsupportedError
  - DigestBase
  - Error
  - HMAC
  - MD5
  - SHA1
  - SSL
    - Context
      - Client
      - Server
    - Error
    - ErrorType
    - Modes
    - Options
    - Socket
      - Client
      - Server
    - VerifyMode
    - X509VerifyFlags
- OptionParser
  - Exception
  - InvalidOption
  - MissingOption
- PartialComparable
- Pointer
  - Appender
- PrettyPrint
- Proc
- Process
  - Env
  - Status
  - Stdio
  - Tms
- Random
  - MT19937
- Range
- Readline
  - CompletionProc
  - KeyBindingProc
- Reference
- Reflect
- Regex
  - MatchData
  - Options
- SecureRandom
- Set
- Signal
- Slice
- Socket
  - Address
  - Addrinfo
  - Error
  - Family
  - IPAddress
  - Protocol
  - Server
  - Type
  - UNIXAddress
- Spec
  - Expectations
  - Methods
  - ObjectExtensions
- StaticArray
- String
  - Builder
  - RawConverter
- StringPool
- StringScanner
- Struct
- Symbol
- System
- TCPServer
- TCPSocket
- Tempfile
- Termios
  - AttributeSelection
  - BaudRate
  - ControlMode
  - InputMode
  - LineControl
  - LocalMode
  - OutputMode
- Time
  - DayOfWeek
  - EpochConverter
  - EpochMillisConverter
  - Format
    - Error
  - Kind
  - MonthSpan
  - Span
- Tuple
- TypeCastError
- UDPSocket
- UInt16
- UInt32
- UInt64
- UInt8
- Unicode
  - CaseOptions
- Union
- UNIXServer
- UNIXSocket
- URI
  - Error
- Value
- WeakRef
- XML
  - Attributes
  - AttributeType
  - Builder
  - Error
  - HTMLParserOptions
  - Namespace
  - Node
  - NodeSet
  - ParserOptions
  - Reader
  - SaveOptions
  - Type
  - XPathContext
- YAML
  - Any
  - Builder
  - Error
  - EventKind
  - ParseException
  - Parser
  - PullParser
  - Type
- Zip
  - CompressionMethod
  - Error
  - File
    - Entry
  - FileInfo
  - Reader
    - Entry
  - Writer
    - Entry
- Zlib
  - Error
  - Reader
  - Writer

# class Logger

- Logger
- Reference
- Object

## Overview

The `Logger` class provides a simple but sophisticated logging utility that you can use to output messages.

The messages have associated levels, such as `INFO` or `ERROR` that indicate their importance. You can then give the `Logger` a level, and only messages at that level of higher will be printed.

For instance, in a production system, you may have your `Logger` set to `INFO` or even `WARN`. When you are developing the system, however, you probably want to know about the program’s internal state, and would set the `Logger` to `DEBUG`.

If logging to multiple locations is required, an `IO::MultiWriter` can be used.

### Example

    require "logger"

    log = Logger.new(STDOUT)
    log.level = Logger::WARN

    log.debug("Created logger")
    log.info("Program started")
    log.warn("Nothing to do!")

    begin
      File.each_line("/foo/bar.log") do |line|
        unless line =~ /^(\w+) = (.*)$/
          log.error("Line in wrong format: #{line}")
        end
      end
    rescue err
      log.fatal("Caught exception; exiting")
      log.fatal(err)
    end

## Defined in:

## Constant Summary

DEBUG = `Severity::DEBUG`
ERROR = `Severity::ERROR`
FATAL = `Severity::FATAL`
INFO = `Severity::INFO`
UNKNOWN = `Severity::UNKNOWN`
WARN = `Severity::WARN`

## Class Method Summary

- .new(io : IO?)

  Creates a new logger that will log to the given io.

## Instance Method Summary

- #close

  Calls the close method on the object passed to `initialize`.

- #debug(progname = nil, &block)

  Logs the message as returned from the given block if the logger's current severity is lower or equal to `DEBUG`.

- #debug(message, progname = nil)

  Logs message if the logger's current severity is lower or equal to `DEBUG`.

- #debug?

  Returns `true` if the logger's current severity is lower or equal to `DEBUG`.

- #error(progname = nil, &block)

  Logs the message as returned from the given block if the logger's current severity is lower or equal to `ERROR`.

- #error(message, progname = nil)

  Logs message if the logger's current severity is lower or equal to `ERROR`.

- #error?

  Returns `true` if the logger's current severity is lower or equal to `ERROR`.

- #fatal(progname = nil, &block)

  Logs the message as returned from the given block if the logger's current severity is lower or equal to `FATAL`.

- #fatal(message, progname = nil)

  Logs message if the logger's current severity is lower or equal to `FATAL`.

- #fatal?

  Returns `true` if the logger's current severity is lower or equal to `FATAL`.

- #formatter : String, Time, String, String, IO -> Nil
- #formatter=(formatter)
- #info(message, progname = nil)

  Logs message if the logger's current severity is lower or equal to `INFO`.

- #info(progname = nil, &block)

  Logs the message as returned from the given block if the logger's current severity is lower or equal to `INFO`.

- #info?

  Returns `true` if the logger's current severity is lower or equal to `INFO`.

- #level : Severity
- #level=(level : Severity)
- #log(severity, message, progname = nil)

  Logs message if severity is higher or equal with the logger's current severity.

- #log(severity, progname = nil, &block)

  Logs the message as returned from the given block if severity is higher or equal with the loggers current severity.

- #progname : String
- #progname=(progname : String)
- #unknown(message, progname = nil)

  Logs message if the logger's current severity is lower or equal to `UNKNOWN`.

- #unknown(progname = nil, &block)

  Logs the message as returned from the given block if the logger's current severity is lower or equal to `UNKNOWN`.

- #unknown?

  Returns `true` if the logger's current severity is lower or equal to `UNKNOWN`.

- #warn(progname = nil, &block)

  Logs the message as returned from the given block if the logger's current severity is lower or equal to `WARN`.

- #warn(message, progname = nil)

  Logs message if the logger's current severity is lower or equal to `WARN`.

- #warn?

  Returns `true` if the logger's current severity is lower or equal to `WARN`.

### Instance methods inherited from class `Reference`

==(other : self)
==(other) ==, dup dup, hash hash, inspect(io : IO) : Nil inspect, object_id : UInt64 object_id, pretty_print(pp) : Nil pretty_print, same?(other : Reference)
same?(other : Nil) same?, to_s(io : IO) : Nil to_s

### Class methods inherited from class `Reference`

new new

### Instance methods inherited from class `Object`

!=(other) !=, !~(other) !~, ==(other) ==, ===(other : JSON::Any)
===(other : YAML::Any)
===(other) ===, =~(other) =~, class class, dup dup, hash hash, inspect(io : IO)
inspect inspect, itself itself, not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, tap(&block) tap, to_json(io : IO)
to_json to_json, to_pretty_json(indent : String = " ")
to_pretty_json(io : IO, indent : String = " ") to_pretty_json, to_s
to_s(io : IO) to_s, to_yaml(io : IO)
to_yaml to_yaml, try(&block) try

### Class methods inherited from class `Object`

from_json(string_or_io, root : String) : self
from_json(string_or_io) : self from_json, from_yaml(string_or_io) : self from_yaml

## Class Method Detail

def self.new(io : IO?) #

Creates a new logger that will log to the given io. If io is `nil` then all log calls will be silently ignored.

## Instance Method Detail

def close #

Calls the close method on the object passed to `initialize`.

def debug(progname = nil, &block) #

Logs the message as returned from the given block if the logger's current severity is lower or equal to `DEBUG`. The block is not run if the severity is higher. progname overrides a default progname set in this logger.

def debug(message, progname = nil) #

Logs message if the logger's current severity is lower or equal to `DEBUG`. progname overrides a default progname set in this logger.

def debug? #

Returns `true` if the logger's current severity is lower or equal to `DEBUG`.

def error(progname = nil, &block) #

Logs the message as returned from the given block if the logger's current severity is lower or equal to `ERROR`. The block is not run if the severity is higher. progname overrides a default progname set in this logger.

def error(message, progname = nil) #

Logs message if the logger's current severity is lower or equal to `ERROR`. progname overrides a default progname set in this logger.

def error? #

Returns `true` if the logger's current severity is lower or equal to `ERROR`.

def fatal(progname = nil, &block) #

Logs the message as returned from the given block if the logger's current severity is lower or equal to `FATAL`. The block is not run if the severity is higher. progname overrides a default progname set in this logger.

def fatal(message, progname = nil) #

Logs message if the logger's current severity is lower or equal to `FATAL`. progname overrides a default progname set in this logger.

def fatal? #

Returns `true` if the logger's current severity is lower or equal to `FATAL`.

def formatter : String, Time, String, String, IO -> Nil #
def formatter=(formatter) #
def info(message, progname = nil) #

Logs message if the logger's current severity is lower or equal to `INFO`. progname overrides a default progname set in this logger.

def info(progname = nil, &block) #

Logs the message as returned from the given block if the logger's current severity is lower or equal to `INFO`. The block is not run if the severity is higher. progname overrides a default progname set in this logger.

def info? #

Returns `true` if the logger's current severity is lower or equal to `INFO`.

def level : Severity #
def level=(level : Severity) #
def log(severity, message, progname = nil) #

Logs message if severity is higher or equal with the logger's current severity. progname overrides a default progname set in this logger.

def log(severity, progname = nil, &block) #

Logs the message as returned from the given block if severity is higher or equal with the loggers current severity. The block is not run if severity is lower. progname overrides a default progname set in this logger.

def progname : String #
def progname=(progname : String) #
def unknown(message, progname = nil) #

Logs message if the logger's current severity is lower or equal to `UNKNOWN`. progname overrides a default progname set in this logger.

def unknown(progname = nil, &block) #

Logs the message as returned from the given block if the logger's current severity is lower or equal to `UNKNOWN`. The block is not run if the severity is higher. progname overrides a default progname set in this logger.

def unknown? #

Returns `true` if the logger's current severity is lower or equal to `UNKNOWN`.

def warn(progname = nil, &block) #

Logs the message as returned from the given block if the logger's current severity is lower or equal to `WARN`. The block is not run if the severity is higher. progname overrides a default progname set in this logger.

def warn(message, progname = nil) #

Logs message if the logger's current severity is lower or equal to `WARN`. progname overrides a default progname set in this logger.

def warn? #

Returns `true` if the logger's current severity is lower or equal to `WARN`.