Module: Outland::TagRunes
- Defined in:
- lib/outland/tag_runes.rb,
lib/outland/tag_runes/version.rb,
lib/outland/tag_runes/rotational_logs.rb
Defined Under Namespace
Modules: MultilineFormatter Classes: Railtie, RotationalLogs
Constant Summary collapse
- GLYPHS =
These glyphs should be chosen to maximize visual distinctiveness while being available in terminal fonts.
%w( a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 6 7 8 9 ᚠ ÿ À Á ᚢ Ã Ä Å Æ Ç È ᚣ Ê Ë Ì Í Î Ï Ð Ñ Ò Ó ᚧ Õ Ö × Ø Ù Ú Û Ü ᛗ ᚸ ᛉ Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ΐ § ¶ Γ Δ © ® ¥ Θ £ ¿ Λ « » Ξ ± Π ¤ Σ ¢ ¡ Φ ° Ψ Ω Ϊ Ϋ ά έ ή ί ΰ α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς σ τ υ φ χ ψ ω ϊ ϋ ό ύ ώ ϐ ϑ ϒ ϓ ϔ ϕ ϖ ϗ Ϙ ϙ Ϛ ϛ Ϝ ϝ Ϟ ϟ Ϡ ϡ Ϣ ϣ Ϥ ϥ Ϧ ϧ Ϩ ϩ Ϫ ϫ Ϭ ϭ Ϯ ϯ ϰ ϱ ♥ Б ♦ ♠ Д ♣ Ж ★ И Й ☉ Л ☇ ☈ ☃ П ☂ ☀ ᛉ ☆ Ф ᛰ Ц Ч Ш Щ Ъ Ы ☥ Э Ю Я )
- VERSION =
"1.1.3"
Class Method Summary collapse
-
.rails_tag ⇒ Object
At this point in the middleware, we don’t have access to the session.
- .sign(hex) ⇒ Object
- .signature(sid, rid) ⇒ Object
Class Method Details
.rails_tag ⇒ Object
At this point in the middleware, we don’t have access to the session. A good approximation is the passed-up session id, although it’s controlled by the client. We ‘sign’ it with a compressed visual representation that doesn’t clutter up the log too badly and is still highly likely to be unique when used for debugging expeditions into the log.
An abbreviated signature of the request id is added as well, to aid in understanding interleaved log entries.
42 43 44 45 46 47 48 49 |
# File 'lib/outland/tag_runes.rb', line 42 def self.rails_tag Proc.new do |req| # Set the tag in the rack environment so it can be picked up by # tools like Airbrake. sess_id = req.[Rails.application.config.[:key]] req.env['request_tag'] = signature(sess_id, req.uuid) end end |
.sign(hex) ⇒ Object
22 23 24 25 26 |
# File 'lib/outland/tag_runes.rb', line 22 def self.sign(hex) hex.scan(/\h\h/).map do |b| GLYPHS[b.to_i(16)] end.join end |
.signature(sid, rid) ⇒ Object
28 29 30 |
# File 'lib/outland/tag_runes.rb', line 28 def self.signature(sid, rid) "#{sid ? sign(sid[0,8]) : '____'} #{sign(rid[0,4])}" end |