Skip to content

Commit

Permalink
MailSender: ボットのロガーを設定できるようにする
Browse files Browse the repository at this point in the history
refs #67
  • Loading branch information
ochaochaocha3 committed May 16, 2016
1 parent b44ea83 commit e2a2395
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/rgrb/plugin/server_connection_report/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class Generator
def configure(config_data)
super

@mail = MailSender.new(config_data['Mail'] || {})
@mail = MailSender.new(config_data['Mail'] || {},
config_data[:logger])
@mail.load_message_template("#{@data_path}/#{config_data['MessageTemplate']}.txt")

self
Expand Down
7 changes: 4 additions & 3 deletions lib/rgrb/plugin/server_connection_report/mail_sender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ module ServerConnectionReport
# メール送信を司るクラス
class MailSender
# 送信データを初期化する
# @param [Hash] config
# @param [Hash] config 設定
# @param [Object] logger ロガー
# @option [String] to 送信先
# @option [Hash] smtp 送信に利用するSMTPサーバーの設定
def initialize(config)
def initialize(config, logger = nil)
if(config['SMTP'])
@mail_config = symbolize_keys(config['SMTP'])
.delete_if do |key, value|
Expand All @@ -22,7 +23,7 @@ def initialize(config)
end
@to = config['To'] || 'root@localhost'

@logger = Lumberjack::Logger.new(
@logger = logger || Lumberjack::Logger.new(
$stdout, progname: self.class.to_s
)
end
Expand Down

0 comments on commit e2a2395

Please sign in to comment.