Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Commit 8dc7cc2

Browse files
author
Shlomi Noach
committed
Merge pull request #21 from github/simplifying-logger
using standard log for host errors
2 parents c607789 + 597c1e9 commit 8dc7cc2

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

go/cmd/ccql/main.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package main
22

33
import (
44
"flag"
5+
"log"
6+
"os/user"
57

68
"github.com/github/ccql/go/logic"
79
"github.com/github/ccql/go/sql"
810
"github.com/github/ccql/go/text"
911

10-
"github.com/outbrain/golib/log"
12+
golib_log "github.com/outbrain/golib/log"
1113
"gopkg.in/gcfg.v1"
12-
"os/user"
1314
)
1415

1516
const (
@@ -18,6 +19,9 @@ const (
1819

1920
// main is the application's entry point. It will either spawn a CLI or HTTP itnerfaces.
2021
func main() {
22+
23+
golib_log.SetLevel(golib_log.FATAL)
24+
2125
osUser := ""
2226
// get os username as owner
2327
if usr, err := user.Current(); err == nil {
@@ -44,7 +48,7 @@ func main() {
4448
}
4549
queries, err := sql.ParseQueries(*queriesText, *queriesFile)
4650
if err != nil {
47-
log.Fatale(err)
51+
log.Fatal(err.Error())
4852
}
4953
if len(queries) == 0 {
5054
log.Fatalf("No query/queries given")
@@ -55,7 +59,7 @@ func main() {
5559
}
5660
hosts, err := text.ParseHosts(*hostsList, *hostsFile)
5761
if err != nil {
58-
log.Fatale(err)
62+
log.Fatal(err.Error())
5963
}
6064
if len(hosts) == 0 {
6165
log.Fatalf("No hosts given")

go/logic/ccql.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package logic
22

33
import (
44
"fmt"
5+
"log"
56
"strings"
67

7-
"github.com/outbrain/golib/log"
88
"github.com/outbrain/golib/sqlutils"
99
)
1010

@@ -14,13 +14,13 @@ func queryHost(host string, user string, password string, defaultSchema string,
1414
mysqlURI := fmt.Sprintf("%s:%s@tcp(%s)/%s?timeout=%ds", user, password, host, defaultSchema, timeout)
1515
db, _, err := sqlutils.GetDB(mysqlURI)
1616
if err != nil {
17-
return log.Errore(err)
17+
return err
1818
}
1919

2020
for _, query := range queries {
2121
resultData, err := sqlutils.QueryResultData(db, query)
2222
if err != nil {
23-
return log.Errorf("%s %s", host, err.Error())
23+
return err
2424
}
2525
for _, row := range resultData {
2626
output := []string{host}
@@ -42,7 +42,9 @@ func QueryHosts(hosts []string, user string, password string, defaultSchema stri
4242
for _, host := range hosts {
4343
go func(host string) {
4444
concurrentHosts <- true
45-
queryHost(host, user, password, defaultSchema, queries, timeout)
45+
if err := queryHost(host, user, password, defaultSchema, queries, timeout); err != nil {
46+
log.Printf("%s %s", host, err.Error())
47+
}
4648
<-concurrentHosts
4749

4850
completedHosts <- true

vendor/github.com/outbrain/golib/sqlutils/sqlutils.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)