class Halite::Logging::JSON

Overview

JSON logging format

Instance variables to check Halite::Logging::Abstract.

In JSON format, if you set skip some key, it will return false.

Halite.use("logging", logging: Halite::Logging::JSON.new(skip_request_body: true))
  .get("http://httpbin.org/get")

# Or
Halite.logging(format: "json", skip_request_body: true)
  .get("http://httpbin.org/get")

Log will look like:

{
  "created_at": "2018-08-31T16:53:57+08:00:00",
  "entry":      {
    "request": {
      "body":      "",
      "headers":   {...},
      "method":    "GET",
      "url":       "http://httpbin.org/anything",
      "timestamp": "2018-08-31T16:53:59+08:00:00",
    },
    "response": {
      "body":         false,
      "header":       {...},
      "status_code":  200,
      "http_version": "HTTP/1.1",
      "timestamp":    "2018-08-31T16:53:59+08:00:00",
    },
  },
}

Defined in:

halite/features/logging/json.cr

Instance Method Summary

Instance methods inherited from class Halite::Logging::Abstract

colorize : Bool colorize, logger=(logger : Log) logger=, request(request) request, response(response) response, skip_benchmark : Bool skip_benchmark, skip_request_body : Bool skip_request_body, skip_response_body : Bool skip_response_body

Constructor methods inherited from class Halite::Logging::Abstract

new(*, for : String = "halite", skip_request_body : Bool = false, skip_response_body : Bool = false, skip_benchmark : Bool = false, colorize : Bool = true) new

Instance Method Detail

def request(request) #

[View source]
def response(response) #

[View source]