Skip to content

util/log: don't print full source path to stderr#8893

Open
ripatel-fd wants to merge 1 commit intofiredancer-io:mainfrom
riptl:dense-logging
Open

util/log: don't print full source path to stderr#8893
ripatel-fd wants to merge 1 commit intofiredancer-io:mainfrom
riptl:dense-logging

Conversation

@ripatel-fd
Copy link
Contributor

@ripatel-fd ripatel-fd commented Mar 16, 2026

Only print the source file name, but not the full source path, to stderr log.

This works because according to C coding best practices compile unit names should be unique.

Before

Screenshot 2026-03-16 at 11 10 43 AM

After

Screenshot 2026-03-16 at 11 35 55 AM

Copilot AI review requested due to automatic review settings March 16, 2026 10:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Firedancer’s logging pipeline so stderr logs show only the source file basename (e.g., fd_metrics.c) rather than the full build-time source path, while keeping the full path available for the logfile output.

Changes:

  • Introduce FD_SRC_FILE to compute a basename for __FILE__ (using __FILE_NAME__ when available).
  • Extend fd_log_private_1 / fd_log_private_2 to accept both path and file_name, and switch stderr formatting to use file_name.
  • Update a few local “NOEXIT” logging macros to pass the new file_name argument.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/util/log/fd_log.h Adds FD_SRC_FILE, updates log macros and private logger prototypes to pass both path and basename.
src/util/log/fd_log.c Implements updated fd_log_private_{1,2} signatures and prints basename to stderr while preserving full path in logfile.
src/disco/keyguard/fd_keyguard_proofs.c Updates CBMC stub prototypes for the new logger function signatures.
src/app/shared_dev/commands/dev.c Updates local FD_LOG_ERR_NOEXIT macro to pass basename argument.
src/app/shared/commands/run/run.c Updates local FD_LOG_ERR_NOEXIT macro to pass basename argument.
src/app/fddev/dev1.c Updates local FD_LOG_ERR_NOEXIT macro to pass basename argument.

You can also share your feedback on Copilot code review. Take the survey.

Only print the source file name, but not the full source path,
to stderr log.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts Firedancer’s logging so stderr output shows only the source file basename (e.g., file.c) instead of the full/relative source path, while preserving the full path in the permanent logfile stream.

Changes:

  • Introduces FD_SRC_FILE to derive the basename of __FILE__ and uses it for stderr-oriented log output.
  • Updates fd_log_private_1/fd_log_private_2 to accept both a full path and a basename, printing basename to stderr and path to the logfile.
  • Updates a few local FD_LOG_ERR_NOEXIT helpers and documentation examples to reflect the new stderr formatting.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/util/log/fd_log.h Adds FD_SRC_FILE, updates log macros and function prototypes, and refreshes example output for stderr.
src/util/log/fd_log.c Implements new fd_log_private_{1,2} signature and switches stderr formatting to use basename.
src/disco/keyguard/fd_keyguard_proofs.c Updates CBMC stub signatures to match new fd_log_private_{1,2} prototypes.
src/app/shared_dev/commands/dev.c Updates local FD_LOG_ERR_NOEXIT macro to pass basename to logging.
src/app/shared/commands/run/run.c Updates local FD_LOG_ERR_NOEXIT macro to pass basename to logging.
src/app/fddev/dev1.c Updates local FD_LOG_ERR_NOEXIT macro to pass basename to logging.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +224 to +227
#define FD_SRC_FILE (__builtin_strrchr( __FILE__, '/' ) ? __builtin_strrchr( __FILE__, '/' ) + 1 : __FILE__) /* compile time fold */
#else
#include <string.h>
#define FD_SRC_FILE (strrchr( __FILE__, '/' ) ? strrchr( __FILE__, '/' ) + 1 : __FILE__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants