Class: DataMapper::Logger
- Object
- DataMapper::Logger
Attributes
Instance Attributes
| aio | [RW] | public |
Sets the attribute aio. |
|---|---|---|---|
| buffer | [RW] | public |
Returns the value of attribute buffer. |
| delimiter | [RW] | public |
Sets the attribute delimiter. |
| level | [RW] | public |
Returns the value of attribute level. |
| log | [RW] | public |
Returns the value of attribute log. |
Constants
- LEVELS
- { :off => 99999, :fatal => 7, :error => 6, :warn => 4, :info => 3, :debug => 0 }
Constructor Summary
public
initialize(*args)
To initialize the logger you create a new object, proxies to set_log.
DataMapper::Logger.new(log{String, IO},level{Symbol, String})
[View source]
145 146 147
# File 'dm-core/lib/dm-core/logger.rb', line 145 def initialize(*args) set_log(*args) end
Public Visibility
Public Instance Method Summary
| #close |
Close and remove the current log object. |
|---|---|
| #flush |
Flush the entire buffer to the log object. |
| #level=(new_level) |
Returns the value of attribute level.. |
| #push(string) |
Appends a string and log level to logger’s buffer. |
| #set_log(log, log_level = :off, delimiter = " ~ ", log_creation = false) |
To replace an existing logger with a new one: DataMapper::Logger. |
Public Instance Methods Inherited from Object
Public Instance Method Details
close
public
close
Close and remove the current log object.
DataMapper.logger.close
[View source]
188 189 190 191 192 193 194
# File 'dm-core/lib/dm-core/logger.rb', line 188 def close flush @log.close if @log.respond_to?(:close) @log = nil end
flush
public
flush
Flush the entire buffer to the log object.
DataMapper.logger.flush
[View source]
180 181 182 183 184 185
# File 'dm-core/lib/dm-core/logger.rb', line 180 def flush return unless @buffer.size > 0 @log.write_method(@buffer.slice!(0..-1).to_s) end
level
public
level=(new_level)
Returns the value of attribute level
[View source]
67 68 69 70
# File 'dm-core/lib/dm-core/logger.rb', line 67 def level=(new_level) @level = LEVELS[new_level.to_sym] reset_methods(:close) end
push
public
push(string)
Appends a string and log level to logger’s buffer.
[View source]
205 206 207
# File 'dm-core/lib/dm-core/logger.rb', line 205 def push(string) internal_push(string) end
set_log
public
set_log(log, log_level = :off, delimiter = " ~ ", log_creation = false)
To replace an existing logger with a new one:
DataMapper::Logger.set_log(log{String, IO},level{Symbol, String})
[View source]
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
# File 'dm-core/lib/dm-core/logger.rb', line 158 def set_log(log, log_level = :off, delimiter = " ~ ", log_creation = false) delimiter ||= " ~ " if log_level && LEVELS[log_level.to_sym] self.level = log_level.to_sym else self.level = :debug end @buffer = [] @delimiter = delimiter initialize_log(log) DataMapper.logger = self self.info("Logfile created") if log_creation end