Rbtz.CredoChecks.Design.PreferLogsterInLib (rbtz_credo_checks v0.1.0)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of normal and works with any version of Elixir.

Explanation

Forbids the standard Logger module in application code under lib/.

This project standardises on Logster for application logs (it adds structured metadata, service-tagging, and request/job correlation that the bare Logger module cannot). Reaching for Logger skips that pipeline and produces logs that won't be correlated or filterable in production.

The check fires when application code calls one of the Logger log-level functions (debug, info, notice, warning, warn, error, critical, alert, emergency, log) or uses require Logger / import Logger. It only inspects files under lib/; test/ and config/ may continue to use Logger directly.

Other Logger functions (e.g. Logger.metadata/0,1, Logger.configure/1) are not flagged — they manage logger state and Logster reads from it.

Bad

# in lib/my_app/orders.ex
require Logger
Logger.info("doing the thing")

Good

# in lib/my_app/orders.ex
Logster.info("doing the thing", order_id: order.id)

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.