Skip to content

Commit 80c9349

Browse files
committed
Removing logging
1 parent c1c9cd2 commit 80c9349

6 files changed

Lines changed: 3 additions & 37 deletions

File tree

command/record.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ func (c RecordCmd) Run(args []string) int {
7575
}
7676

7777
if err := event.Record(fileToRecord); err != nil && !(err == project.ErrNotInitialized || err == project.ErrFileNotFound) {
78-
if err := project.Log(err); err != nil {
79-
c.Ui.Error(err.Error())
80-
}
8178
return 1
8279
} else if err == nil && status {
8380
var (

event/manager.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
package event
66

77
import (
8-
"fmt"
98
"io/ioutil"
109
"os"
1110
"path/filepath"
1211
"strconv"
1312
"strings"
1413

1514
"github.com/git-time-metric/gtm/epoch"
16-
"github.com/git-time-metric/gtm/project"
1715
)
1816

1917
// Record creates an event for a source
@@ -65,10 +63,7 @@ func Process(gtmPath string, interim bool) (map[int64]map[string]int, error) {
6563

6664
sourcePath, err := readEventFile(eventFilePath)
6765
if err != nil {
68-
project.Log(fmt.Sprintf("\nRemoving corrupt event file %s, %s\n", eventFilePath, err))
69-
if err := os.Remove(eventFilePath); err != nil {
70-
project.Log(fmt.Sprintf("\nError removing event file %s, %s\n", eventFilePath, err))
71-
}
66+
os.Remove(eventFilePath)
7267
continue
7368
}
7469

main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"os"
99

1010
"github.com/git-time-metric/gtm/command"
11-
"github.com/git-time-metric/gtm/project"
1211
"github.com/mitchellh/cli"
1312
)
1413

@@ -64,9 +63,7 @@ func main() {
6463

6564
exitStatus, err := c.Run()
6665
if err != nil {
67-
if err := project.Log(err); err != nil {
68-
ui.Error(err.Error())
69-
}
66+
ui.Error(err.Error())
7067
}
7168

7269
os.Exit(exitStatus)

metric/metric.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616

1717
"github.com/git-time-metric/gtm/epoch"
1818
"github.com/git-time-metric/gtm/note"
19-
"github.com/git-time-metric/gtm/project"
2019
"github.com/git-time-metric/gtm/scm"
2120
"github.com/git-time-metric/gtm/util"
2221
)
@@ -187,10 +186,7 @@ func loadMetrics(gtmPath string) (map[string]FileMetric, error) {
187186

188187
metricFile, err := readMetricFile(metricFilePath)
189188
if err != nil {
190-
project.Log(fmt.Sprintf("Removing corrupt metric file %s, %s", metricFilePath, err))
191-
if err := os.Remove(metricFilePath); err != nil {
192-
project.Log(fmt.Sprintf("Unable to delete corrupt metric file %s, %s", metricFilePath, err))
193-
}
189+
os.Remove(metricFilePath)
194190
continue
195191
}
196192

project/project.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"errors"
1010
"fmt"
1111
"io/ioutil"
12-
"log"
1312
"os"
1413
"path/filepath"
1514
"runtime"
@@ -312,23 +311,6 @@ func Paths(wd ...string) (string, string, error) {
312311
return repoPath, gtmPath, nil
313312
}
314313

315-
// Log logs to a gtm log in the GTMDir
316-
func Log(v ...interface{}) error {
317-
_, gtmPath, err := Paths()
318-
if err != nil {
319-
return err
320-
}
321-
f, err := os.OpenFile(filepath.Join(gtmPath, "gtm.log"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
322-
if err != nil {
323-
return fmt.Errorf("error opening log file: %v", err)
324-
}
325-
defer func() { _ = f.Close() }()
326-
log.SetOutput(f)
327-
328-
log.Println(v)
329-
return nil
330-
}
331-
332314
func removeTags(gtmPath string) error {
333315
files, err := ioutil.ReadDir(gtmPath)
334316
if err != nil {

report/query.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func retrieveNotes(projects []ProjectCommits, terminalOff bool) commitNoteDetail
3434
var commitNote note.CommitNote
3535
commitNote, err = note.UnMarshal(n.Note)
3636
if err != nil {
37-
project.Log(fmt.Sprintf("Error unmarshalling note \n\n%s \n\n%s", n.Note, err))
3837
commitNote = note.CommitNote{}
3938
}
4039

0 commit comments

Comments
 (0)