Class: LoggoRails::Formatter
- Inherits:
-
Logger::Formatter
- Object
- Logger::Formatter
- LoggoRails::Formatter
- Defined in:
- lib/loggo_rails/formatter.rb
Constant Summary collapse
- REGEX_SESSION_IP =
- 123213-12312-1231-123
- 123.123.123.123
-
body of message
/^\[(?<session>[^\]]+)\]\s\[(?<ip>[^\]]+)\]\s(?<content>.+)/m.freeze
- REGEX_STARTED =
Started GET “/api/v1/albums” for 127.0.0.1 at 2017-04-26 19:03:33 -0300
/Started (?<method>[\S]+) "(?<path>[^"]+)" for (?<ip>[\S]+) at (?<time>.+)/.freeze
- REGEX_PROCESSING =
Processing by Api::V1::AlbumsController#update as JSON
/Processing by (?<controller>[^\#]+)\#(?<action>\w+) as (?<format>\w+)/.freeze
- REGEX_PARAMETERS =
Parameters: “status”=>“draft”, “view_mode”=>“list”, “cover”=>“”}
/Parameters: (?<parameters>.+)/.freeze
- REGEX_UNPERMITTED_PARAMETERS =
Unpermitted parameters: group, slug, autoFocus, focused, oldName
/Unpermitted parameters: (?<unpermittedparameters>[\w, ]+)/.freeze
- REGEX_SQL =
SQL (3.5ms) INSERT INTO ‘albuns` (`id_cliente`, `titulo`, `url`, `capa`, `status`) VALUES (3, ’asdsadas’, ‘asdsadas’, ”, ‘draft’) Album Load (0.7ms) SELECT ‘albuns`.* FROM `albuns` WHERE `albuns`.`deleted_at` IS NULL AND `albuns`.`id_cliente` = 3 AND `albuns`.`id` = 22898 LIMIT 1 Client Load (3.6ms) SELECT `clientes`.* FROM `clientes` WHERE `clientes`.`id` = 3 LIMIT 1 SQL (4.3ms) DELETE FROM `categorias` WHERE `categorias`.`id` = 7
/(SQL|(?<model>[\S]+) [\S]+)\s+\((?<time>[^)]+)\)\s+(?<query>.+)/.freeze
- REGEX_RENDERED =
Rendered api/v1/categories/show.rabl (1.0ms)
/Rendered (?<view>\S+) \((?<time>[^\)]+)\)/.freeze
- REGEX_RENDERING =
Rendering api/v1/categories/show.rabl
/Rendering (<view>\S+)/ .freeze
- REGEX_COMPLETED_FULL =
Completed 201 Created in 65ms (Views: 10.4ms | ActiveRecord: 38.2ms) Completed 404 Not Found in 13ms (Views: 0.2ms | ActiveRecord: 0.8ms) Completed 204 No Content in 172ms (ActiveRecord: 67.1ms)
/Completed (?<response>\d+) .+ in (?<time>\S+)(?<details>.+)?/.freeze
- REGEX_COMPLETED_VIEWS =
(Views: 10.4ms | ActiveRecord: 38.2ms) (Views: 0.2ms | ActiveRecord: 0.8ms) (ActiveRecord: 67.1ms)
/Views: (?<time>[^\s\)]+)/.freeze
- REGEX_COMPLETED_ACTIVE_RECORD =
(Views: 10.4ms | ActiveRecord: 38.2ms) (Views: 0.2ms | ActiveRecord: 0.8ms) (ActiveRecord: 67.1ms)
/ActiveRecord: (?<time>[^\s\)]+)/.freeze
Instance Attribute Summary collapse
-
#sync ⇒ Object
readonly
Returns the value of attribute sync.
Instance Method Summary collapse
- #call(severity, time, progname, msg) ⇒ Object
-
#initialize ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize ⇒ Formatter
Returns a new instance of Formatter.
48 49 50 |
# File 'lib/loggo_rails/formatter.rb', line 48 def initialize @sync = LoggoRails::Sync.new end |
Instance Attribute Details
#sync ⇒ Object (readonly)
Returns the value of attribute sync.
46 47 48 |
# File 'lib/loggo_rails/formatter.rb', line 46 def sync @sync end |
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/loggo_rails/formatter.rb', line 52 def call(severity, time, progname, msg) Thread.new do parsed = msg2str(msg), progname return unless parsed node, descr, content = parsed sync.write( app: Rails.configuration.loggo_rails.app_name, log: { timestamp: time, type: severity, node: node, description: descr, content: content } ) end super end |