Skip to content

Conversation

@serdarozerr
Copy link
Contributor

@serdarozerr serdarozerr commented Jan 19, 2026

Context

The existing logging implementation relied on legacy, unstructured log output written exclusively to stderr. There was no consistent use of log levels across the codebase, which made it difficult to control verbosity and distinguish between informational, warning, and error messages.

Due to the lack of structured logging, log output could not be reliably scraped or indexed by centralized logging systems such as ELK. Additionally, there was no option to persist logs to a file, and no proper debugging capability to capture full request/response flows for external service calls.

Solution

Changes Introduced

  • Migrated logging to slog with a JSON handler, enabling structured, key–value based logs suitable for log aggregation and analysis pipelines.
  • Introduced consistent log levels across the codebase: debug, info, warn, and error.
  • Added a configurable --log-level flag to control runtime verbosity.
    • Defaults to warn to avoid excessive logging in normal operation.
  • Added a --log-file flag to optionally stream logs to a file.
    • Default behavior remains unchanged: logs are written to stderr when no file is specified.
  • Implemented debug mode support for gcs and alioss clients:
    • When --log-level=debug is enabled, both clients capture and log full request/response pairs to support deep debugging and troubleshooting.
  • For the Azurebs client, SDK-level debug logging cannot be enabled via a runtime flag, as the Azure Go SDK depends solely on the environment variable AZURE_SDK_GO_LOGGING="all" for request/response tracing (see: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore/log).
  • Instead, existing Azurebs log statements were migrated to slog, ensuring consistency with the structured logging approach used across the codebase.
  • For the S3 client, refactoring is deferred until the ongoing development in the main repository is completed
    (https://github.com/cloudfoundry/bosh-s3cli).
  • Once the upstream changes are finalized, the updated implementation will be pulled into this repository and adapted accordingly.

- slog added with some configuration, seting up debug level, writes to file if provided
- debug flag added to run in debug mode, this will run clients in debug mode to see all request/responses
- A middleware for logging request/responses for gcs client added
- a new config for general purpose introduced. It is a singletion and can be accessed in anywhere. Debug flag added into it, it can be extented further with some other config parameters.
- log lines in main and gcs client replaced with slog
- log-level added instead of debug option
- slog info option injected into RunGCSCLI to print some logs which are being used in some test casses
- all logs converted to slog
- log messages improved
- failing test cases due to the new messges are adapted
- log replaced with slog
- debug mode for the ali client is added
- log messages are refactored
- integration tests refactored to be compatible with log messages if required
- runcli for integratio tests is run with info level to grap log messages
@serdarozerr serdarozerr marked this pull request as ready for review January 20, 2026 08:36
@github-project-automation github-project-automation bot moved this from Inbox to Pending Merge | Prioritized in Foundational Infrastructure Working Group Jan 20, 2026
@johha johha merged commit f220667 into cloudfoundry:main Jan 20, 2026
3 of 7 checks passed
@github-project-automation github-project-automation bot moved this from Pending Merge | Prioritized to Done in Foundational Infrastructure Working Group Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants