Class: ATNA::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/atna/logger.rb

Constant Summary collapse

VALID_OPTIONS =

ATNA メッセージ構築用パラメータ

[:pri, :version, :timestamp, :hostname, :app_name, :procid, :msgid, :structured_data]
UTF8_BOMB =

ATNA 用の UTF-8 BOMB

0xEFBBBF
PRI =

PRI の値

"<85>"
MSGID =

MSGID の値(ATNA では固定値)

"IHE+RFC-3881"

Instance Method Summary collapse

Constructor Details

#initialize(host = 'localhost', port = 514, default_options = { }) ⇒ Logger

Returns a new instance of Logger.



19
20
21
22
# File 'lib/atna/logger.rb', line 19

def initialize(host = 'localhost', port = 514, default_options = { })
  @host, @port = host, port
  @default_options = default_options
end

Instance Method Details

#notify!(xmlmsg, options = { }) ⇒ Object

メッセージを送信

xmlmsg

送信すべき XML メッセージ本体

options
:version

バージョン番号

:timestamp

Time インスタンス(未指定時は現在時刻を利用)

:hostname

メッセージ発信元 hostname(未指定時はホスト名を取得:localhost時は - を設定)

:app_name

アプリケーション名(未指定時は - を設定)

:procid

プロセスID(未指定時は - を設定)

:msgid

メッセージID(未指定時は - を設定)

:structured_data

構造化データ



35
36
37
38
39
40
41
42
43
# File 'lib/atna/logger.rb', line 35

def notify!(xmlmsg, options = { })
  options = @default_options.merge(options)
  validate_options(options)
  update_blank_options(options)

  sender = UdpSender.new(@host, @port)
  datagram = serialize_message(xmlmsg, options)
  sender.send(datagram)
end