Module: MailDiode
- Defined in:
- lib/maildiode-plugins/alias.rb,
lib/util.rb,
lib/util.rb,
lib/engine.rb,
lib/engine.rb,
lib/engine.rb,
lib/server.rb,
lib/maildir.rb,
lib/settings.rb,
lib/maildiode-plugins/delay.rb,
lib/maildiode-plugins/blacklist.rb
Overview
You should have received a copy of the GNU General Public License along with this program. If not, see <www.gnu.org/licenses/>.
Defined Under Namespace
Classes: AliasFilter, BlacklistFilter, ComponentSettings, DelayFilter, DeliverableMessage, Engine, Envelope, Filter, FilterableData, FolderMissingError, MailHandler, MaildirMessageHandler, SMTPError, Server, Settings, SingleSetting, UTCFormatter
Constant Summary
collapse
- NEWLINE =
"\r\n"
- NOOP =
'NOOP'
- HELO =
'HELO'
- EHLO =
'EHLO'
- QUIT =
'QUIT'
- RSET =
'RSET'
- VRFY =
'VRFY'
- MAIL =
'MAIL'
- RCPT =
'RCPT'
- DATA =
'DATA'
- RESULT_BYE =
'221 Bye'
- RESULT_OK =
'250 Ok'
- RESULT_UNSURE =
'252'
- RESULT_DATA_OK =
'354'
- ACCEPTED =
:accepted
- NO_OPINION =
:no_opinion
Class Method Summary
collapse
Class Method Details
.clear_log ⇒ Object
69
70
71
|
# File 'lib/util.rb', line 69
def self.clear_log
@log_buffer.truncate(0)
end
|
.flush_log ⇒ Object
73
74
75
|
# File 'lib/util.rb', line 73
def self.flush_log
@log_stream.flush
end
|
.get_log ⇒ Object
65
66
67
|
# File 'lib/util.rb', line 65
def self.get_log
return @log_buffer.string
end
|
.log_debug(message) ⇒ Object
92
93
94
95
|
# File 'lib/util.rb', line 92
def self.log_debug(message)
@log.debug(message)
flush_log
end
|
.log_error(message) ⇒ Object
77
78
79
80
|
# File 'lib/util.rb', line 77
def self.log_error(message)
@log.error(message)
flush_log
end
|
.log_info(message) ⇒ Object
87
88
89
90
|
# File 'lib/util.rb', line 87
def self.log_info(message)
@log.info(message)
flush_log
end
|
.log_success(command, args, result) ⇒ Object
97
98
99
|
# File 'lib/util.rb', line 97
def self.log_success(command, args, result)
log_debug("#{result}: #{command} #{args}")
end
|
.log_to_console ⇒ Object
41
42
43
44
|
# File 'lib/util.rb', line 41
def self.log_to_console
@log_buffer = nil
log_to_stream(STDERR)
end
|
.log_to_file(file_path) ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/util.rb', line 46
def self.log_to_file(file_path)
is_safe = !file_path.index('..')
if !is_safe
raise "Log file path cannot contain .."
end
file_path.untaint
@log_buffer = nil
out = File.open(file_path, 'a')
log_to_stream(out)
end
|
.log_to_stream(destination) ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/util.rb', line 57
def self.log_to_stream(destination)
level = @log ? @log.level : Logger::WARN
@log_stream = destination
@log = Logger.new(destination, 'monthly')
@log.formatter = UTCFormatter.new
@log.level = level
end
|
.log_to_string ⇒ Object
36
37
38
39
|
# File 'lib/util.rb', line 36
def self.log_to_string
@log_buffer = StringIO.new('', 'w')
log_to_stream(@log_buffer)
end
|
.log_warning(message) ⇒ Object
82
83
84
85
|
# File 'lib/util.rb', line 82
def self.log_warning(message)
@log.warn(message)
flush_log
end
|
.set_log_level(level) ⇒ Object
101
102
103
|
# File 'lib/util.rb', line 101
def self.set_log_level(level)
@log.level = level
end
|