-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logging): enable api/sdk interaction logging (#237)
# 📥 Pull Request ## ❓ What are you trying to address This pull request introduces logging enhancements for API/SDK interactions and updates related documentation and configuration files. The key changes include enabling detailed logging for API calls and updating the troubleshooting guide. ## ✨ Description of new changes ### Logging Enhancements: * Added a new logging subsystem for the Microsoft Fabric SDK to capture detailed API interactions. (`internal/provider/client/logging.go`) * Integrated the new logging subsystem into the provider client creation process. (`internal/provider/provider.go`) ### Documentation Updates: * Updated the troubleshooting guide to include instructions for enabling low-level logging for API calls. (`docs/guides/troubleshooting.md`, `templates/guides/troubleshooting.md`) --------- Co-authored-by: Pablo Zaidenvoren <[email protected]>
- Loading branch information
1 parent
db76154
commit 70af222
Showing
8 changed files
with
125 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
kind: added | ||
body: Enable API/SDK interaction logging. | ||
time: 2025-02-06T13:30:34.6324433+01:00 | ||
custom: | ||
Issue: "237" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Microsoft Corporation | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package client | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
"github.com/hashicorp/go-hclog" | ||
"github.com/hashicorp/terraform-plugin-log/tflog" | ||
) | ||
|
||
const ( | ||
FabricSDKLoggerName = "fabric-sdk-go" | ||
AzureSDKLoggingEnvVar = "AZURE_SDK_GO_LOGGING" | ||
AzureSDKLoggingAll = "all" | ||
) | ||
|
||
func NewFabricSDKLoggerSubsystem(ctx context.Context) (context.Context, hclog.Level, error) { | ||
targetLevel := hclog.LevelFromString(os.Getenv("FABRIC_SDK_GO_LOGGING")) | ||
|
||
// If the level is not set, or is set to "off", disable logging | ||
if targetLevel == hclog.NoLevel { | ||
targetLevel = hclog.Off | ||
} else { | ||
// Enable azcore logging | ||
err := os.Setenv(AzureSDKLoggingEnvVar, AzureSDKLoggingAll) | ||
if err != nil { | ||
return ctx, targetLevel, err | ||
} | ||
} | ||
|
||
ctx = tflog.NewSubsystem(ctx, FabricSDKLoggerName, tflog.WithLevel(targetLevel)) | ||
ctx = tflog.SubsystemMaskFieldValuesWithFieldKeys(ctx, FabricSDKLoggerName, "Authorization") | ||
|
||
return ctx, targetLevel, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters