Class: Sapience::Subscriber

Inherits:
Base
  • Object
show all
Extended by:
Descendants
Defined in:
lib/sapience/subscriber.rb

Direct Known Subclasses

Appender::Stream, Appender::Wrapper

Instance Attribute Summary collapse

Attributes inherited from Base

#filter

Instance Method Summary collapse

Methods included from Descendants

descendants

Methods inherited from Base

#fast_tag, #level=, #payload, #pop_tags, #push_tags, #silence, #tagged, #tags, #with_payload

Methods included from LogMethods

#debug, #debug?, #error, #error!, #error?, #fatal, #fatal!, #fatal?, #info, #info?, #level_to_index, #log_with_exception, #log_with_level, #measure, #measure_debug, #measure_error, #measure_fatal, #measure_info, #measure_trace, #measure_warn, #trace, #trace?, #warn, #warn?

Instance Attribute Details

#app_nameObject

Allow app_name to be set globally or per subscriber



55
56
57
# File 'lib/sapience/subscriber.rb', line 55

def app_name
  @app_name || Sapience.app_name
end

#formatterObject

Every logger has its own formatter



7
8
9
# File 'lib/sapience/subscriber.rb', line 7

def formatter
  @formatter
end

#hostObject

Allow host name to be set globally or per subscriber



60
61
62
# File 'lib/sapience/subscriber.rb', line 60

def host
  @host || Sapience.config.host
end

Instance Method Details

#closeObject

A subscriber should implement close if it can.



45
46
47
# File 'lib/sapience/subscriber.rb', line 45

def close
  # NOOP
end

#default_formatterObject

Returns [Sapience::Formatters::Default] formatter default for this subscriber



50
51
52
# File 'lib/sapience/subscriber.rb', line 50

def default_formatter
  Sapience::Formatters::Default.new
end

#flushObject

A subscriber should implement flush if it can.



18
19
20
# File 'lib/sapience/subscriber.rb', line 18

def flush
  # NOOP
end

#levelObject

Returns the current log level if set, otherwise it logs everything it receives



13
14
15
# File 'lib/sapience/subscriber.rb', line 13

def level
  @level || :trace
end

#nameObject



40
41
42
# File 'lib/sapience/subscriber.rb', line 40

def name
  self.class.name
end

#to_sObject

TODO: Implement a format string with class name and interesting values see:

- https://www.rubysteps.com/articles/2015/customize-your-ruby-classes-with-to-s-and-inspect/
- http://stackoverflow.com/questions/9524698/override-to-s-while-keeping-output-of-inspect
- http://stackoverflow.com/questions/2625667/why-do-this-ruby-object-have-both-to-s-and-inspect-methods-that-appear-to-do-the


36
37
38
# File 'lib/sapience/subscriber.rb', line 36

def to_s
  name
end

#valid?Boolean

TODO: Implement this mehtod in all appenders TODO: Output relevant message when appender isn’t valid TODO: Check this valid? method before using appender, output above error message if not valid? TODO: Wait with adding appenders until they are needed solve this by below TODO: Implement possibility of finding and deleting appenders by env

Returns:

  • (Boolean)


27
28
29
# File 'lib/sapience/subscriber.rb', line 27

def valid?
  fail NotImplementedError, "needs to be implemented in appender"
end