log smudge errors

This commit is contained in:
Rick Olson 2014-08-07 15:33:29 -06:00
parent a3795ffb51
commit f960932fa6
2 changed files with 10 additions and 4 deletions

@ -53,7 +53,7 @@ func smudgeCommand(cmd *cobra.Command, args []string) {
if err != nil {
ptr.Encode(os.Stdout)
Error("Error accessing media: %s (%s)", filename, ptr.Oid)
LoggedError(err, "Error accessing media: %s (%s)", filename, ptr.Oid)
}
}

@ -59,15 +59,21 @@ func Debug(format string, args ...interface{}) {
log.Printf(format, args...)
}
// Panic prints a formatted message, and writes a stack trace for the error to
// a log file before exiting.
func Panic(err error, format string, args ...interface{}) {
// LoggedError prints a formatted message to Stderr and writes a stack trace for
// the error to a log file without exiting.
func LoggedError(err error, format string, args ...interface{}) {
Error(format, args...)
file := handlePanic(err)
if len(file) > 0 {
fmt.Fprintf(os.Stderr, "\nErrors logged to %s.\nUse `git media logs last` to view the log.\n", file)
}
}
// Panic prints a formatted message, and writes a stack trace for the error to
// a log file before exiting.
func Panic(err error, format string, args ...interface{}) {
LoggedError(err, format, args...)
os.Exit(2)
}