Crash reporting shouldn't be static

Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
David Gageot
2016-01-05 11:14:53 +01:00
parent cd9301e252
commit f5293e10e2
4 changed files with 73 additions and 41 deletions

View File

@@ -132,8 +132,18 @@ func (api *Client) Create(h *host.Host) error {
log.Info("Creating machine...")
if err := api.performCreate(h); err != nil {
sendCrashReport(err, api, h)
return err
vBoxLog := ""
if h.DriverName == "virtualbox" {
vBoxLog = filepath.Join(api.GetMachinesDir(), h.Name, h.Name, "Logs", "VBox.log")
}
return crashreport.CrashError{
Cause: err,
Command: "Create",
Context: "api.performCreate",
DriverName: h.DriverName,
LogFilePath: vBoxLog,
}
}
log.Debug("Reticulating splines...")
@@ -185,15 +195,6 @@ func (api *Client) performCreate(h *host.Host) error {
return nil
}
func sendCrashReport(err error, api *Client, host *host.Host) {
if host.DriverName == "virtualbox" {
vboxlogPath := filepath.Join(api.GetMachinesDir(), host.Name, host.Name, "Logs", "VBox.log")
crashreport.SendWithFile(err, "api.performCreate", host.DriverName, "Create", vboxlogPath)
} else {
crashreport.Send(err, "api.performCreate", host.DriverName, "Create")
}
}
func (api *Client) Close() error {
return api.clientDriverFactory.Close()
}