Created
August 9, 2012 17:30
-
-
Save mpage/3306220 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::Membrane::SchemaParser.parse do | |
{ | |
"base_dir" => String, | |
optional("local_route") => String, | |
"logging" => { | |
"level" => String, | |
optional("file") => String, | |
optional("syslog") => String, | |
}, | |
"nats_uri" => String, | |
"pid_filename" => String, | |
"runtimes" => dict(String, Dea::Runtime.schema), | |
"warden_socket" => String, | |
"index" => Integer, | |
"directory_server_port" => Integer, | |
optional("status") => { | |
optional("user") => String, | |
optional("port") => Integer, | |
optional("password") => String, | |
}, | |
optional("intervals") => { | |
optional("heartbeat") => Integer, | |
optional("advertise") => Integer, | |
}, | |
optional("resources") => { | |
optional("memory_mb") => Integer, | |
optional("memory_overcommit_factor") => enum(Float, Integer), | |
optional("disk_mb") => Integer, | |
optional("disk_overcommit_factor") => enum(Float, Integer), | |
optional("num_instances") => Integer, | |
}, | |
} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "thread" | |
require "steno" | |
STDOUT.sync = true | |
config = Steno::Config.new(:sinks => [Steno::Sink::IO.new(STDOUT)], | |
:codec => Steno::Codec::Json.new, | |
:context => Steno::Context::ThreadLocal.new) | |
Steno.init(config) | |
zazzle = proc do |request_id| | |
Steno.config.context.data["request_id"] = request_id | |
logger = Steno.logger("zazzle") | |
5.times do |ii| | |
logger.info("Iteration #{ii}") | |
sleep 1 | |
end | |
end | |
t1 = Thread.new { zazzle.call("request1") } | |
t2 = Thread.new { zazzle.call("request2") } | |
[t1, t2].each { |t| t.join } | |
request_logger = Steno.logger("test").tag("request_id" => "request3") | |
request_logger.info("Hello world") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ruby /tmp/steno_example.rb | steno-prettify | |
2012-08-09 10:53:27.066400 zazzle pid=16587 tid=a2ef fid=5748 tmp/steno_example.rb/block (2 levels) in <main>:19 request_id=request1 INFO -- Iteration 0 | |
2012-08-09 10:53:27.066585 zazzle pid=16587 tid=719d fid=2713 tmp/steno_example.rb/block (2 levels) in <main>:19 request_id=request2 INFO -- Iteration 0 | |
2012-08-09 10:53:28.066823 zazzle pid=16587 tid=a2ef fid=5748 tmp/steno_example.rb/block (2 levels) in <main>:19 request_id=request1 INFO -- Iteration 1 | |
2012-08-09 10:53:28.067021 zazzle pid=16587 tid=719d fid=2713 tmp/steno_example.rb/block (2 levels) in <main>:19 request_id=request2 INFO -- Iteration 1 | |
2012-08-09 10:53:29.067203 zazzle pid=16587 tid=a2ef fid=5748 tmp/steno_example.rb/block (2 levels) in <main>:19 request_id=request1 INFO -- Iteration 2 | |
2012-08-09 10:53:29.067486 zazzle pid=16587 tid=719d fid=2713 tmp/steno_example.rb/block (2 levels) in <main>:19 request_id=request2 INFO -- Iteration 2 | |
2012-08-09 10:53:30.067608 zazzle pid=16587 tid=a2ef fid=5748 tmp/steno_example.rb/block (2 levels) in <main>:19 request_id=request1 INFO -- Iteration 3 | |
2012-08-09 10:53:30.067764 zazzle pid=16587 tid=719d fid=2713 tmp/steno_example.rb/block (2 levels) in <main>:19 request_id=request2 INFO -- Iteration 3 | |
2012-08-09 10:53:31.068120 zazzle pid=16587 tid=719d fid=2713 tmp/steno_example.rb/block (2 levels) in <main>:19 request_id=request2 INFO -- Iteration 4 | |
2012-08-09 10:53:31.068418 zazzle pid=16587 tid=a2ef fid=5748 tmp/steno_example.rb/block (2 levels) in <main>:19 request_id=request1 INFO -- Iteration 4 | |
2012-08-09 10:53:32.068922 test pid=16587 tid=ef32 fid=6cd5 tmp/steno_example.rb/<main>:31 request_id=request3 INFO -- Hello world |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ruby /tmp/steno_example.rb | |
{"timestamp":1344534761.9690974,"message":"Iteration 0","log_level":"info","source":"zazzle","data":{"request_id":"request1"},"thread_id":19727000,"fiber_id":19723560,"process_id":15241,"file":"/tmp/steno_example.rb","lineno":19,"method":"block (2 levels) in <main>"} | |
{"timestamp":1344534761.9693959,"message":"Iteration 0","log_level":"info","source":"zazzle","data":{"request_id":"request2"},"thread_id":19726900,"fiber_id":19705660,"process_id":15241,"file":"/tmp/steno_example.rb","lineno":19,"method":"block (2 levels) in <main>"} | |
{"timestamp":1344534762.9698203,"message":"Iteration 1","log_level":"info","source":"zazzle","data":{"request_id":"request1"},"thread_id":19727000,"fiber_id":19723560,"process_id":15241,"file":"/tmp/steno_example.rb","lineno":19,"method":"block (2 levels) in <main>"} | |
{"timestamp":1344534762.9701777,"message":"Iteration 1","log_level":"info","source":"zazzle","data":{"request_id":"request2"},"thread_id":19726900,"fiber_id":19705660,"process_id":15241,"file":"/tmp/steno_example.rb","lineno":19,"method":"block (2 levels) in <main>"} | |
{"timestamp":1344534763.9702857,"message":"Iteration 2","log_level":"info","source":"zazzle","data":{"request_id":"request1"},"thread_id":19727000,"fiber_id":19723560,"process_id":15241,"file":"/tmp/steno_example.rb","lineno":19,"method":"block (2 levels) in <main>"} | |
{"timestamp":1344534763.9705114,"message":"Iteration 2","log_level":"info","source":"zazzle","data":{"request_id":"request2"},"thread_id":19726900,"fiber_id":19705660,"process_id":15241,"file":"/tmp/steno_example.rb","lineno":19,"method":"block (2 levels) in <main>"} | |
{"timestamp":1344534764.9708934,"message":"Iteration 3","log_level":"info","source":"zazzle","data":{"request_id":"request2"},"thread_id":19726900,"fiber_id":19705660,"process_id":15241,"file":"/tmp/steno_example.rb","lineno":19,"method":"block (2 levels) in <main>"} | |
{"timestamp":1344534764.9710948,"message":"Iteration 3","log_level":"info","source":"zazzle","data":{"request_id":"request1"},"thread_id":19727000,"fiber_id":19723560,"process_id":15241,"file":"/tmp/steno_example.rb","lineno":19,"method":"block (2 levels) in <main>"} | |
{"timestamp":1344534765.9715345,"message":"Iteration 4","log_level":"info","source":"zazzle","data":{"request_id":"request2"},"thread_id":19726900,"fiber_id":19705660,"process_id":15241,"file":"/tmp/steno_example.rb","lineno":19,"method":"block (2 levels) in <main>"} | |
{"timestamp":1344534765.9718492,"message":"Iteration 4","log_level":"info","source":"zazzle","data":{"request_id":"request1"},"thread_id":19727000,"fiber_id":19723560,"process_id":15241,"file":"/tmp/steno_example.rb","lineno":19,"method":"block (2 levels) in <main>"} | |
{"timestamp":1344534766.9723432,"message":"Hello world","log_level":"info","source":"test","data":{"request_id":"request3"},"thread_id":17483240,"fiber_id":19570800,"process_id":15241,"file":"/tmp/steno_example.rb","lineno":31,"method":"<main>"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment