Skip to content

Commit

Permalink
Fix #26 Add Verbose mode to be easier to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
rach committed Jan 7, 2016
1 parent b051abf commit e441341
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
Short('p').Default("2345").PlaceHolder("PORT").Int()
sslmode = app.Flag("sslmode", "database SSL mode (default: disable)").
Short('s').Default("disable").PlaceHolder("SSLMODE").String()
verbose = app.Flag("verbose", "").Short('v').Bool()
password = app.Flag("password", "").Short('W').Bool()
username = addUsernameFlag(app)
database = app.Arg("DBNAME", "").Required().String()
Expand Down
12 changes: 12 additions & 0 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ type TableBloatDatabaseResult struct {
type databaseResultFct func(db *sqlx.DB) interface{}

func GetIndexBloatResult(db *sqlx.DB) interface{} {
if *verbose {
log.Printf("Fetch Indexes Bloat")
}
r := []IndexBloatDatabaseResult{}
err := db.Select(&r, IndexBloatSql)
if err != nil {
Expand All @@ -56,6 +59,9 @@ func GetIndexBloatResult(db *sqlx.DB) interface{} {
}

func GetTableBloatResult(db *sqlx.DB) interface{} {
if *verbose {
log.Printf("Fetch Tables Bloat")
}
r := []TableBloatDatabaseResult{}
err := db.Select(&r, TableBloatSql)
if err != nil {
Expand All @@ -65,6 +71,9 @@ func GetTableBloatResult(db *sqlx.DB) interface{} {
}

func GetNumberOfConnectionResult(db *sqlx.DB) interface{} {
if *verbose {
log.Printf("Fetch Number of Connections")
}
r := NumberOfConnectionResult{}
err := db.Get(&r, NumberOfConnectionSql)
if err != nil {
Expand All @@ -74,6 +83,9 @@ func GetNumberOfConnectionResult(db *sqlx.DB) interface{} {
}

func GetDatabeSizeResult(db *sqlx.DB) interface{} {
if *verbose {
log.Printf("Fetch Database Size")
}
r := DatabaseSizeResult{}
err := db.Get(&r, DatabaseSizeSql)
if err != nil {
Expand Down

0 comments on commit e441341

Please sign in to comment.