-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Debug logging This PR adds debug logging. Debug logging can be enabled through flags to the yamlfmt command, and will tell you in very noisy detail about things that are going on. Debug groups are separated into codes, so that only certain debug logs can be enabled if you are debugging a specific problem. I also fixed a bug I introduced in the last config PR with the `-conf` flag. It is fixed before ever going out in a release, so it will only affect someone who installed from that exact commit before I fix it here. * Fix integration test files, add -no_global_conf The integration test files got accidentally formatted by some local testing, this sets them back to what they should be. Also adds a new flag that that disables usage of configuration file from system home.
- Loading branch information
Showing
13 changed files
with
165 additions
and
60 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
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
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
2 changes: 1 addition & 1 deletion
2
integrationtest/command/testdata/include_document_start/before/x.yaml
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
hello: | ||
world: 1 | ||
world: 1 |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
6tark: | ||
does: 64 | ||
does: 64 |
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,37 @@ | ||
package logger | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/google/yamlfmt/internal/collections" | ||
) | ||
|
||
type DebugCode int | ||
|
||
const ( | ||
DebugCodeAny DebugCode = iota | ||
DebugCodeConfig | ||
DebugCodePaths | ||
) | ||
|
||
var ( | ||
supportedDebugCodes = map[string][]DebugCode{ | ||
"config": {DebugCodeConfig}, | ||
"paths": {DebugCodePaths}, | ||
"all": {DebugCodeConfig, DebugCodePaths}, | ||
} | ||
activeDebugCodes = collections.Set[DebugCode]{} | ||
) | ||
|
||
func ActivateDebugCode(code string) { | ||
if debugCodes, ok := supportedDebugCodes[code]; ok { | ||
activeDebugCodes.Add(debugCodes...) | ||
} | ||
} | ||
|
||
// Debug prints a message if the given debug code is active. | ||
func Debug(code DebugCode, msg string, args ...any) { | ||
if activeDebugCodes.Contains(code) { | ||
fmt.Printf("[DEBUG]: %s\n", fmt.Sprintf(msg, args...)) | ||
} | ||
} |
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
Oops, something went wrong.