Skip to content

Add log level configuration and tests for logger functionality#448

Open
Nicklas2751 wants to merge 1 commit intopaketo-buildpacks:mainfrom
Nicklas2751:447_add_option_disable_logs
Open

Add log level configuration and tests for logger functionality#448
Nicklas2751 wants to merge 1 commit intopaketo-buildpacks:mainfrom
Nicklas2751:447_add_option_disable_logs

Conversation

@Nicklas2751
Copy link
Copy Markdown

@Nicklas2751 Nicklas2751 commented Jan 12, 2026

Closes #447

Summary

This pull request introduces a configurable logging system to libpak, allowing users to control log verbosity using the BP_LOG_LEVEL and BP_DEBUG environment variables. The changes add a new log level hierarchy, update the logger implementation to respect these levels, and provide comprehensive tests and documentation.

Log Level Configuration and Implementation:

  • Introduced a LogLevel type with levels (none, error, info, debug) and logic to parse and select the active level based on BP_LOG_LEVEL and BP_DEBUG environment variables. BP_DEBUG takes precedence, and unknown values default to info. (log/logger.go)
  • Updated the logger initialization in NewPaketoLoggerWithOptions to enable or disable specific writers based on the configured log level, ensuring only relevant logs are emitted. (log/logger.go)

Testing:

  • Added unit and integration tests to verify parsing of log levels, correct environment variable precedence, and logger output at each level. (log/logger_test.go)

Documentation:

  • Expanded the README.md with a new section explaining log level configuration, use cases, environment variable precedence, and caveats. (README.md)

Use Cases

Let user control if and how much logging they want. Disable logging is useful for containers running processes or servers in a buildpack container that communicate via stdio like a MCP server. See #447

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.
  • I'm happy with the commit history on this PR (I have rebased/squashed as needed).

@Nicklas2751 Nicklas2751 requested a review from a team as a code owner January 12, 2026 20:57
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Jan 12, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Nicklas2751 / name: Nicklas Wiegandt (d6efb23)

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.

Option to disable info logs via log level (BP_LOG_LEVEL = error/none)

1 participant