View Source ExJsonLogger.Ecto.Logger (ex_json_logger v1.4.0)

An Ecto Logger replacement which captures and logs Ecto.LogEntry attributes through metadata.

Logger Metadata available:

  • query - the query as string;
  • query_params - the query parameters as string;
  • query_time - the time spent executing the query in milliseconds;
  • decode_time - the time spent decoding the result in milliseconds;
  • queue_time - the time spent to check the connection out in milliseconds;

Metadata is filtered by default so keys will need to be whitelisted.

Usage

Add ExJsonLogger.Ecto.Logger to the Repo's configuration under the :loggers key.

config :sample, Sample.Repo,
  adapter: Ecto.Adapters.MySQL,
  username: "root",
  password: "",
  database: "sample_dev",
  hostname: "localhost",
  pool_size: 10,
  loggers: [{ExJsonLogger.Ecto.Logger, :log, []}]

Summary

Functions

Link to this function

log(entry, level \\ :debug)

View Source
@spec log(Ecto.LogEntry.t(), Logger.level()) :: Ecto.LogEntry.t()