X Tutup
Skip to content

Commit f10584e

Browse files
committed
Remove remaining log.Fatal
Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
1 parent ac7e323 commit f10584e

File tree

6 files changed

+14
-31
lines changed

6 files changed

+14
-31
lines changed

cmd/machine.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,12 @@ func runDriver(driverName string) {
204204
}
205205

206206
func cmdNotFound(c *cli.Context, command string) {
207-
log.Fatalf(
207+
log.Errorf(
208208
"%s: '%s' is not a %s command. See '%s --help'.",
209209
c.App.Name,
210210
command,
211211
c.App.Name,
212212
os.Args[0],
213213
)
214+
os.Exit(1)
214215
}

commands/ls.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ func matchesName(host *host.Host, names []string) bool {
312312
for _, n := range names {
313313
r, err := regexp.Compile(n)
314314
if err != nil {
315-
// TODO: remove that call to Fatal
316-
log.Fatal(err)
315+
log.Error(err)
316+
os.Exit(1) // TODO: Can we get rid of this call, and exit 'properly' ?
317317
}
318318
if r.MatchString(host.Driver.GetMachineName()) {
319319
return true

libmachine/examples/vbox_create.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,34 @@ func main() {
2525

2626
data, err := json.Marshal(driver)
2727
if err != nil {
28-
log.Fatal(err)
28+
log.Error(err)
29+
return
2930
}
3031

3132
h, err := client.NewHost("virtualbox", data)
3233
if err != nil {
33-
log.Fatal(err)
34+
log.Error(err)
35+
return
3436
}
3537

3638
h.HostOptions.EngineOptions.StorageDriver = "overlay"
3739

3840
if err := client.Create(h); err != nil {
39-
log.Fatal(err)
41+
log.Error(err)
42+
return
4043
}
4144

4245
out, err := h.RunSSHCommand("df -h")
4346
if err != nil {
44-
log.Fatal(err)
47+
log.Error(err)
48+
return
4549
}
4650

4751
fmt.Printf("Results of your disk space query:\n%s\n", out)
4852

4953
fmt.Println("Powering down machine now...")
5054
if err := h.Stop(); err != nil {
51-
log.Fatal(err)
55+
log.Error(err)
56+
return
5257
}
5358
}

libmachine/log/fmt_machine_logger.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,6 @@ func (ml *FmtMachineLogger) Infof(fmtString string, args ...interface{}) {
6969
fmt.Fprintf(ml.outWriter, fmtString+"\n", args...)
7070
}
7171

72-
func (ml *FmtMachineLogger) Fatal(args ...interface{}) {
73-
ml.history.Record(args...)
74-
fmt.Fprintln(ml.errWriter, args...)
75-
os.Exit(1)
76-
}
77-
78-
func (ml *FmtMachineLogger) Fatalf(fmtString string, args ...interface{}) {
79-
ml.history.Recordf(fmtString, args...)
80-
fmt.Fprintf(ml.errWriter, fmtString+"\n", args...)
81-
os.Exit(1)
82-
}
83-
8472
func (ml *FmtMachineLogger) Warn(args ...interface{}) {
8573
ml.history.Record(args...)
8674
fmt.Fprintln(ml.outWriter, args...)

libmachine/log/log.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ func Infof(fmtString string, args ...interface{}) {
4949
logger.Infof(fmtString, args...)
5050
}
5151

52-
func Fatal(args ...interface{}) {
53-
logger.Fatal(args...)
54-
}
55-
56-
func Fatalf(fmtString string, args ...interface{}) {
57-
logger.Fatalf(fmtString, args...)
58-
}
59-
6052
func Warn(args ...interface{}) {
6153
logger.Warn(args...)
6254
}

libmachine/log/machine_logger.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ type MachineLogger interface {
1717
Info(args ...interface{})
1818
Infof(fmtString string, args ...interface{})
1919

20-
Fatal(args ...interface{})
21-
Fatalf(fmtString string, args ...interface{})
22-
2320
Warn(args ...interface{})
2421
Warnf(fmtString string, args ...interface{})
2522

0 commit comments

Comments
 (0)
X Tutup