etils icon indicating copy to clipboard operation
etils copied to clipboard

Double logging in eapp.better_logging()

Open chicham opened this issue 1 year ago • 1 comments

Description

The eapp.better_logging() function causes double logging - each log message appears twice.

Commit eacd5c99 added py_logging.getLogger().addHandler(python_handler) which creates a duplicate logging path since ABSLHandler already delegates to python_handler internally.

Reproduction

#!/usr/bin/env python3
# /// script
# requires-python = ">=3.9"
# dependencies = [
#   "etils[eapp]",
#   "absl-py",
# ]
# ///
"""Minimal working example showing double logging bug."""

import logging

from absl import app
from etils import eapp


def main(_):
    logging.info("Hello world")


if __name__ == "__main__":
    eapp.better_logging()
    app.run(main)

Run with: uv run test_double_logging.py

Output shows double logging:

I 15:55:04 [test_double_logging.py:18]: Hello world
I 15:55:04 [test_double_logging.py:18]: Hello world

chicham avatar Oct 03 '25 14:10 chicham

Hi 👋 Thanks for the clear repro and analysis — I’ll take a look and try to put together a small fix with a test.

CodeVishal-17 avatar Jan 05 '26 13:01 CodeVishal-17