Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add changes to logging format. #6

Merged
merged 4 commits into from
Aug 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Return nil if error occurs during execution pgbackrest command.
Also write pgbackrest error to log.
woblerr committed Aug 4, 2021
commit a39e9324f2b1ce916945b41cebf7cb7483aeabbd
2 changes: 1 addition & 1 deletion backrest/backrest_exporter.go
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ func GetPgBackRestInfo(config, configIncludePath string, stanzas []string, verbo
for _, stanza := range stanzas {
stanzaData, err := getAllInfoData(config, configIncludePath, stanza)
if err != nil {
log.Printf("[ERROR] Get data from pgBackRest failed, %v - %v", err, string(stanzaData))
log.Printf("[ERROR] Get data from pgBackRest failed, %v", err)
}
parseStanzaData, err := parseResult(stanzaData)
if err != nil {
2 changes: 1 addition & 1 deletion backrest/backrest_exporter_test.go
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ func TestGetPgBackRestInfo(t *testing.T) {
args{"", "", []string{""}, false},
`Forty two`,
1,
"[ERROR] Parse JSON failed, invalid character 'F' looking for beginning of value"},
"[ERROR] pgBackRest error: Forty two"},
{"GetPgBackRestInfoZeroDataReturn",
args{"", "", []string{""}, false},
`[]`,
9 changes: 6 additions & 3 deletions backrest/backrest_parser.go
Original file line number Diff line number Diff line change
@@ -206,10 +206,13 @@ func getAllInfoData(config, configIncludePath, stanza string) ([]byte, error) {
}
// Finally arguments for exec command
concatArgs := concatExecArgs(args)
// pgBackRest writes errors to stderr.
// If an error occurs when execution pgBackRest,
// we will get the error text instead of the data.
out, err := execCommand(app, concatArgs...).CombinedOutput()
// If error occurs - write error from pgBackRest to log and
// return nil for stanza data.
if err != nil {
log.Printf("[ERROR] pgBackRest error: %v", string(out))
return nil, err
}
return out, err
}