Module: Log

Extended by:
Comfort
Defined in:
lib/log.rb,
lib/log/file.rb,
lib/log/entry.rb,
lib/log/nolog.rb,
lib/log/fakeio.rb,
lib/log/comfort.rb,
lib/log/forward.rb,
lib/log/methods.rb,
lib/log/filereader.rb

Overview

Description

log/entry.rb provides some convenience methods in Log.

Synopsis

log(“Some info”) log(“Danger!”, :warn) warn(“Danger!”) debug(“mecode was here”)

Defined Under Namespace

Modules: Comfort, FakeIO, Methods Classes: Entry, File, FileReader, Forward, NoLog

Constant Summary collapse

GroupSeparator =
"\x1d"
RecordSeparator =
"\x1e"
UnitSeparator =
"\x1f"
RecordTerminator =
"\n"
Printable =

currently unused

"%d#{RecordSeparator}%s#{RecordSeparator}%s#{RecordSeparator}%s"
Serialized =

currently only used by Entry#serialize, but not by Entry::deserialize

"%d#{RecordSeparator}" \
"%s#{RecordSeparator}" \
"%s#{RecordSeparator}" \
"%s#{RecordSeparator}" \
"%s#{RecordSeparator}" \
"%s"

Instance Attribute Summary

Attributes included from Comfort

#logger

Class Method Summary collapse

Methods included from Comfort

debug, error, exception, fail, info, log, warn

Class Method Details

.escape(data) ⇒ Object

escape binary data, the data will contain no n, r or t‘s after escaping, but still contain binary characters, but all of them preceeded by e



52
53
54
55
56
57
58
59
# File 'lib/log.rb', line 52

def self.escape(data)
	data.
		gsub(/\e/, "\e\e").
		gsub(/\n/, "\en").
		gsub(/\r/, "\er").
		gsub(/\t/, "\et").
		gsub(/[\x00-\x1a\x1c-\x1f]/, "\e\\0")
end

.file(*args) ⇒ Object

Log.file is equivalent to Log::File.new



17
18
19
# File 'lib/log/file.rb', line 17

def self.file(*args)
	Log::File.new(*args)
end

.forward(*args) ⇒ Object

Log.forward is equivalent to Log::Forward.new



16
17
18
# File 'lib/log/forward.rb', line 16

def self.forward(*args)
	Forward.new(*args)
end

.unescape(data) ⇒ Object

unescapes data escaped by Log.escape



62
63
64
65
66
67
68
# File 'lib/log.rb', line 62

def self.unescape(data)
	data.
		gsub(/\en/, "\n").
		gsub(/\er/, "\r").
		gsub(/\et/, "\t").
		gsub(/\e(.)/, '\1')
end