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

Commit 4035610

Browse files
committed
proper logrus usage
1 parent f649354 commit 4035610

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

cmd/mt-update-ttl/main.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func main() {
8585
session, err := NewCassandraStore()
8686

8787
if err != nil {
88-
panic(fmt.Sprintf("Failed to instantiate cassandra: %s", err))
88+
log.Fatalf("Failed to instantiate cassandra: %s", err)
8989
}
9090

9191
update(session, ttl, tableIn, tableOut)
@@ -182,26 +182,26 @@ func worker(id int, jobs <-chan string, wg *sync.WaitGroup, session *gocql.Sessi
182182
query = fmt.Sprintf("INSERT INTO %s (data, key, ts) values(?,?,?) USING TTL %d", tableOut, newTTL)
183183
}
184184
if *verbose {
185-
log.Printf("id=%d processing rownum=%d table=%q key=%q ts=%d query=%q data='%x'\n", id, atomic.LoadUint64(&doneRows)+1, tableIn, key, ts, query, data)
185+
log.Infof("id=%d processing rownum=%d table=%q key=%q ts=%d query=%q data='%x'\n", id, atomic.LoadUint64(&doneRows)+1, tableIn, key, ts, query, data)
186186
}
187187

188188
err := session.Query(query, data, key, ts).Exec()
189189
if err != nil {
190-
fmt.Fprintf(os.Stderr, "ERROR: id=%d failed updating %s %s %d: %q", id, tableOut, key, ts, err)
190+
log.Errorf("id=%d failed updating %s %s %d: %q", id, tableOut, key, ts, err)
191191
}
192192

193193
doneRowsSnap := atomic.AddUint64(&doneRows, 1)
194194
if doneRowsSnap%10000 == 0 {
195195
doneKeysSnap := atomic.LoadUint64(&doneKeys)
196196
completeness := completenessEstimate(token)
197-
log.Printf("WORKING: id=%d processed %d keys, %d rows. (last token: %d, completeness estimate %.1f%%)", id, doneKeysSnap, doneRowsSnap, token, completeness*100)
197+
log.Infof("WORKING: id=%d processed %d keys, %d rows. (last token: %d, completeness estimate %.1f%%)", id, doneKeysSnap, doneRowsSnap, token, completeness*100)
198198
}
199199
}
200200
err := iter.Close()
201201
if err != nil {
202202
doneKeysSnap := atomic.LoadUint64(&doneKeys)
203203
doneRowsSnap := atomic.LoadUint64(&doneRows)
204-
fmt.Fprintf(os.Stderr, "ERROR: id=%d failed querying %s: %q. processed %d keys, %d rows", id, tableIn, err, doneKeysSnap, doneRowsSnap)
204+
log.Errorf("id=%d failed querying %s: %q. processed %d keys, %d rows", id, tableIn, err, doneKeysSnap, doneRowsSnap)
205205
}
206206
atomic.AddUint64(&doneKeys, 1)
207207
}
@@ -229,11 +229,11 @@ func update(session *gocql.Session, ttl int, tableIn, tableOut string) {
229229
if err != nil {
230230
doneKeysSnap := atomic.LoadUint64(&doneKeys)
231231
doneRowsSnap := atomic.LoadUint64(&doneRows)
232-
fmt.Fprintf(os.Stderr, "ERROR: failed querying %s: %q. processed %d keys, %d rows", tableIn, err, doneKeysSnap, doneRowsSnap)
232+
log.Errorf("failed querying %s: %q. processed %d keys, %d rows", tableIn, err, doneKeysSnap, doneRowsSnap)
233233
wg.Wait()
234234
os.Exit(2)
235235
}
236236

237237
wg.Wait()
238-
log.Printf("DONE. Processed %d keys, %d rows", doneKeys, doneRows)
238+
log.Infof("DONE. Processed %d keys, %d rows", doneKeys, doneRows)
239239
}

0 commit comments

Comments
 (0)