Skip to content

Commit

Permalink
Improved logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Izak Marais committed Jun 20, 2017
1 parent 6706689 commit f03ca76
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions report.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (rep *Report) renderPNGsParallel(dash grafana.Dashboard) (err error) {
defer wg.Done()
err = rep.renderPNG(p)
if err != nil {
log.Printf("Error creating image for panel: %v", err)
return
}
}(p)
Expand All @@ -110,26 +111,29 @@ func (rep *Report) renderPNGsParallel(dash grafana.Dashboard) (err error) {
return
}

func (rep *Report) renderPNG(p grafana.Panel) (err error) {
func (rep *Report) renderPNG(p grafana.Panel) error {
body, err := rep.gClient.GetPanelPng(p, rep.dashName, rep.time)
if err != nil {
return
return fmt.Errorf("error getting panel: %v", err)
}
defer body.Close()

err = os.MkdirAll(rep.imgDirPath(), 0777)
if err != nil {
return
return fmt.Errorf("error creating img directory:%v", err)
}
imgFileName := fmt.Sprintf("image%d.png", p.Id)
file, err := os.Create(filepath.Join(rep.imgDirPath(), imgFileName))
if err != nil {
return
return fmt.Errorf("error creating image file:%v", err)
}
defer file.Close()

_, err = io.Copy(file, body)
return
if err != nil {
return fmt.Errorf("error copying body to file:%v", err)
}
return nil
}

func (rep *Report) generateTeXFile(dash grafana.Dashboard) (err error) {
Expand Down

0 comments on commit f03ca76

Please sign in to comment.