40. Syslog
• Standard logging solution for Unix/Linux
• Facility (daemon, cron, user, local0, etc.)
• Priority/Level (Alert, Critical, Error,
Warning, etc.)
• Client and server
• Since 1980
41. ... It also provides devices
which would otherwise be
unable to communicate a
means to notify administrators
of problems or performance.
http://en.wikipedia.org/wiki/Syslog
42. Syslog Format
Date Hostname Program : Message
Jan 1 12:12:12 10.245.3.99 foo[421] : this is a message
43. Syslog client
# man logger
logger -p local0.notice -t HOSTIDM My Message
62. class WebApp < Sinatra::Base
def self.connections
@connections ||= []
end
get '/stream' do
content_type 'text/event-stream'
stream(:keep_open) do |out|
WebApp.connections << out
end
end
end
63. class WebApp < Sinatra::Base
# send the message to all clients
def self.send_event(event = {})
connections.each do |c|
if c.closed
connections.delete(c)
else
c << "event: #{event[:event]}n"
c << "data: #{event[:data]}nn"
end
end
end
# here go sinatra routes ...
end
64. # disable sinatra's autorun
disable :run
EM.run do
WebApp.run!
UdpServer.run
Signal.trap("INT") { EventMachine.stop }
Signal.trap("TERM") { EventMachine.stop }
end