Class: Cogger::Configuration

Inherits:
Data
  • Object
show all
Defined in:
lib/cogger/configuration.rb

Overview

Defines the default configuration for all pipes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: Program.call, io: $stdout, level: Level.call, formatter: Formatters::Emoji.new, datetime_format: DATETIME_FORMAT, tags: Core::EMPTY_ARRAY, header: false, mode: false, age: nil, size: 1_048_576, suffix: "%Y-%m-%d", entry: Entry, logger: Logger, mutex: Mutex.new) ⇒ Configuration

Returns a new instance of Configuration.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cogger/configuration.rb', line 27

def initialize id: Program.call,
               io: $stdout,
               level: Level.call,
               formatter: Formatters::Emoji.new,
               datetime_format: DATETIME_FORMAT,
               tags: Core::EMPTY_ARRAY,
               header: false,
               mode: false,
               age: nil,
               size: 1_048_576,
               suffix: "%Y-%m-%d",
               entry: Entry,
               logger: Logger,
               mutex: Mutex.new
  super.tap { tags.freeze }
end

Instance Attribute Details

#ageObject (readonly)

Returns the value of attribute age

Returns:

  • (Object)

    the current value of age



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def age
  @age
end

#datetime_formatObject (readonly)

Returns the value of attribute datetime_format

Returns:

  • (Object)

    the current value of datetime_format



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def datetime_format
  @datetime_format
end

#entryObject (readonly)

Returns the value of attribute entry

Returns:

  • (Object)

    the current value of entry



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def entry
  @entry
end

#formatterObject (readonly)

Returns the value of attribute formatter

Returns:

  • (Object)

    the current value of formatter



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def formatter
  @formatter
end

#headerObject (readonly)

Returns the value of attribute header

Returns:

  • (Object)

    the current value of header



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def header
  @header
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def id
  @id
end

#ioObject (readonly)

Returns the value of attribute io

Returns:

  • (Object)

    the current value of io



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def io
  @io
end

#levelObject (readonly)

Returns the value of attribute level

Returns:

  • (Object)

    the current value of level



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def level
  @level
end

#loggerObject (readonly)

Returns the value of attribute logger

Returns:

  • (Object)

    the current value of logger



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def logger
  @logger
end

#modeObject (readonly)

Returns the value of attribute mode

Returns:

  • (Object)

    the current value of mode



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def mode
  @mode
end

#mutexObject (readonly)

Returns the value of attribute mutex

Returns:

  • (Object)

    the current value of mutex



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def mutex
  @mutex
end

#sizeObject (readonly)

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def size
  @size
end

#suffixObject (readonly)

Returns the value of attribute suffix

Returns:

  • (Object)

    the current value of suffix



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def suffix
  @suffix
end

#tagsObject (readonly)

Returns the value of attribute tags

Returns:

  • (Object)

    the current value of tags



9
10
11
# File 'lib/cogger/configuration.rb', line 9

def tags
  @tags
end

Instance Method Details

#entag(other = nil) ⇒ Object



44
# File 'lib/cogger/configuration.rb', line 44

def entag(other = nil) = other ? tags.including(other) : tags

#inspectObject



59
60
61
62
63
64
# File 'lib/cogger/configuration.rb', line 59

def inspect
  "#<#{self.class} @id=#{id}, @io=#{io.class}, @level=#{level}, " \
  "@formatter=#{formatter.class}, @datetime_format=#{datetime_format.inspect}, " \
  "@tags=#{tags.inspect}, @header=#{header}, @mode=#{mode}, @age=#{age}, @size=#{size}, " \
  "@suffix=#{suffix.inspect}, @entry=#{entry}, @logger=#{logger}>"
end

#to_loggerObject



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/cogger/configuration.rb', line 46

def to_logger
  logger.new io,
             age,
             size,
             progname: id,
             level:,
             formatter:,
             datetime_format:,
             skip_header: skip_header?,
             binmode: mode,
             shift_period_suffix: suffix
end