Module: CustomLogger

Defined in:
lib/customlogger.rb

Constant Summary collapse

LOOP_LIMIT =
2048
SECTION_HTML =
'<section><hr></section>'

Class Method Summary collapse

Class Method Details

.auto_clearObject



78
79
80
# File 'lib/customlogger.rb', line 78

def auto_clear
  @auto_clear
end

.auto_clear=(value) ⇒ Object



74
75
76
# File 'lib/customlogger.rb', line 74

def auto_clear=(value)
  @auto_clear = value
end

.clearObject



69
70
71
72
# File 'lib/customlogger.rb', line 69

def clear
  new_log_file
  'Wiped All Old Logs'
end

.debug(value, title = nil) ⇒ Object



94
95
96
97
98
# File 'lib/customlogger.rb', line 94

def debug(value, title=nil)
  clear if @auto_clear
  log(:debug, value, title)
  value
end

.demoObject



117
118
119
120
121
122
123
124
125
# File 'lib/customlogger.rb', line 117

def demo
  clear
  error 'This is an error message...', 'Error'
  warning 'This is a warning message...', 'Warning'
  info 'This is an info message...', 'Info'
  debug 'This is an debug message...', 'Debug'
  raw 'This is an raw message...', 'Raw'
  [ 'Demo complete for file: ', file ].join
end

.error(value, title = nil) ⇒ Object



82
83
84
85
86
# File 'lib/customlogger.rb', line 82

def error(value, title=nil)
  clear if @auto_clear
  log(:error, value, title)
  value
end

.error_color(state, color) ⇒ Object



56
57
58
# File 'lib/customlogger.rb', line 56

def error_color(state, color)
  @error_colors[state] = color
end

.error_colorsObject



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

def error_colors
  @error_colors
end

.fileObject



40
41
42
43
44
45
46
# File 'lib/customlogger.rb', line 40

def file
  if @file_name.nil? || @file_name == ''
    'custom_logger.html' 
  else
    @file_name
  end
end

.file=(value) ⇒ Object



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

def file=(value)
  @file_name = value
end

.info(value, title = nil) ⇒ Object



100
101
102
103
104
# File 'lib/customlogger.rb', line 100

def info(value, title=nil)
  clear if @auto_clear
  log(:info, value, title)
  value
end

.newObject



64
65
66
67
# File 'lib/customlogger.rb', line 64

def new
  new_log_file
  'Wiped All Old Logs'
end

.new_lineObject



112
113
114
115
# File 'lib/customlogger.rb', line 112

def new_line
  log(:section, nil, nil)
  SECTION_HTML
end

.pathObject



28
29
30
31
32
33
34
# File 'lib/customlogger.rb', line 28

def path
  if @log_path.nil? || @log_path == ''
    [ Dir.pwd, '/log' ].join
  else
    @log_path
  end
end

.path=(value) ⇒ Object



24
25
26
# File 'lib/customlogger.rb', line 24

def path=(value)
  @log_path = value
end

.raw(value, title = nil) ⇒ Object



106
107
108
109
110
# File 'lib/customlogger.rb', line 106

def raw(value, title=nil)
  clear if @auto_clear
  log(:raw, value, title)
  value
end

.titleObject



52
53
54
# File 'lib/customlogger.rb', line 52

def title
  @title
end

.title=(value) ⇒ Object



48
49
50
# File 'lib/customlogger.rb', line 48

def title=(value)
  @title = value
end

.warning(value, title = nil) ⇒ Object



88
89
90
91
92
# File 'lib/customlogger.rb', line 88

def warning(value, title=nil)
  clear if @auto_clear
  log(:warning, value, title)
  value
end