new: centralized logging and implemented DELETE /api/events route, closes #5

This commit is contained in:
evilsocket 2018-01-08 06:39:44 +01:00
commit f1f146d3d7
21 changed files with 144 additions and 184 deletions

View file

@ -1,23 +1,20 @@
package core
import (
"github.com/op/go-logging"
"fmt"
"os/exec"
"strings"
)
var log = logging.MustGetLogger("mitm")
func Exec(executable string, args []string) (string, error) {
path, err := exec.LookPath(executable)
if err != nil {
return "", err
}
log.Debugf(DIM+"Exec( '%s %s' )"+RESET+"\n", path, strings.Join(args, " "))
raw, err := exec.Command(path, args...).CombinedOutput()
if err != nil {
log.Errorf(" err=%s out='%s'\n", err, raw)
fmt.Printf("ERROR: path=%s args=%s err=%s out='%s'\n", path, args, err, raw)
return "", err
} else {
return strings.Trim(string(raw), "\r\n\t "), nil