diff --git a/db.go b/db.go index cc90640..151cc91 100644 --- a/db.go +++ b/db.go @@ -327,6 +327,10 @@ func NewEvent(domain, action string) *Event { } } +func (e *Event) String() string { + return fmt.Sprintf("%s %s %s %s", e.Domain, e.Action, e.Entity, string(e.Args)) +} + func (e *Event) Log(db *gorm.DB) { if len(e.ArgsMap) > 0 { var err error @@ -334,7 +338,7 @@ func (e *Event) Log(db *gorm.DB) { log.Printf("error: %v", err) } } - log.Printf("event: %v", e) + log.Printf("info: %s", e) if err := db.Create(e).Error; err != nil { log.Printf("warning: %v", err) } diff --git a/dbinit.go b/dbinit.go index a0b880c..9e10c02 100644 --- a/dbinit.go +++ b/dbinit.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "io/ioutil" "log" "os" "time" @@ -12,7 +13,9 @@ import ( ) func dbInit(db *gorm.DB) error { + log.SetOutput(ioutil.Discard) db.Callback().Delete().Replace("gorm:delete", hardDeleteCallback) + log.SetOutput(os.Stderr) m := gormigrate.New(db, gormigrate.DefaultOptions, []*gormigrate.Migration{ { @@ -530,7 +533,7 @@ func dbInit(db *gorm.DB) error { if err := db.Create(&user).Error; err != nil { return err } - log.Printf("Admin user created, use the user 'invite:%s' to associate a public key with this account", user.InviteToken) + log.Printf("info 'admin' user created, use the user 'invite:%s' to associate a public key with this account", user.InviteToken) } // create host ssh key diff --git a/main.go b/main.go index 50e421a..3546a73 100644 --- a/main.go +++ b/main.go @@ -269,6 +269,6 @@ func server(c *cli.Context) error { return nil }) - log.Printf("SSH Server accepting connections on %s", c.String("bind-address")) + log.Printf("info: SSH Server accepting connections on %s", c.String("bind-address")) return ssh.ListenAndServe(c.String("bind-address"), nil, opts...) }