2323
2424module JavaBuildpack ::Diagnostics
2525
26+ # Factory for the buildpack diagnostic logger.
2627 class LoggerFactory
2728 # Create a Logger for the given application directory.
2829 #
@@ -116,18 +117,25 @@ def self.close
116117 end
117118 end
118119
120+ # A +Logger+ destination which delegates to multiple underlying destinations.
119121 class LogSplitter
122+ # Initializes a +LogSplitter+ with a given array of destinations.
123+ # @param [Array] destinations an array of destinations
120124 def initialize ( *destinations )
121125 @destinations = destinations
122126 end
123127
128+ # Writes to the underlying destinations.
129+ #
130+ # @param [Array] args the arguments for the delegated call
124131 def write ( *args )
125132 @destinations . each do |destination |
126133 destination . write ( *args )
127134 destination . flush
128135 end
129136 end
130137
138+ # Closes the underlying destinations.
131139 def close
132140 @destinations . each do |destination |
133141 destination . close
@@ -136,11 +144,19 @@ def close
136144
137145 end
138146
147+ # A subclass of the standard +Logger+ which determines the caller from the stack.
139148 class Logger < ::Logger
149+ # Initializes a Logger.
150+ # @param [Object] log_dev the destination 'device' to log to
140151 def initialize ( log_dev )
141152 super
142153 end
143154
155+ # Logs a message with a given severity.
156+ #
157+ # @param [String] severity the severity of the log message
158+ # @param [Object, nil] message the message to be logged
159+ # @param [String, nil] progname the name of the program logging the message
144160 def add ( severity , message = nil , progname = nil , &block )
145161
146162 if message || block_given?
@@ -158,6 +174,7 @@ def add(severity, message = nil, progname = nil, &block)
158174 super ( severity , message_text , program_name , &block )
159175 end
160176
177+ # Closes the logger.
161178 def close
162179 warn ( caller [ 0 ] ) { 'logger is being closed' }
163180 super
0 commit comments