annotation Logit::Log

Overview

Annotation to mark methods for automatic logging instrumentation.

When a method is annotated with @[Logit::Log], Logit automatically:

Basic Usage

class UserService
  @[Logit::Log]
  def find_user(id : Int32) : User?
    User.find(id)
  end
end

With Options

class AuthService
  @[Logit::Log(log_args: false, redact: ["password"])]
  def authenticate(username : String, password : String) : Bool
    # password won't be logged
  end

  @[Logit::Log(name: "user_logout", level: Logit::LogLevel::Debug)]
  def logout(user : User) : Nil
    # Custom span name and debug level
  end
end

Defined in:

logit/logit.cr