Skip to content

Commit

Permalink
syslog wrapper update
Browse files Browse the repository at this point in the history
  • Loading branch information
yunchao_liu committed Jul 11, 2018
1 parent 89ede68 commit d292037
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
17 changes: 8 additions & 9 deletions eventmon/monitord/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (m *Monitor) notify(event eventmon.EventV0, ip string, logger log.Logger, T
case eventmon.EventTypeServiceProviderLogin:
logger.Printf("User %s logged into service: %s\n",
event.Username, event.ServiceProviderUrl)
//m.TeeLogger.one.Notice(fmt.Sprintf("%s: User %s logged into service: %s", ip, event.Username, event.ServiceProviderUrl))
Teelog.Print(fmt.Sprintf("%s: User %s logged into service: %s", ip, event.Username, event.ServiceProviderUrl))
select { // Non-blocking notification.
case m.serviceProviderLoginChannel <- SPLoginInfo{
URL: event.ServiceProviderUrl,
Expand All @@ -318,25 +318,25 @@ func (m *Monitor) notify(event eventmon.EventV0, ip string, logger log.Logger, T
}
if pubKey, err := ssh.ParsePublicKey(event.CertData); err != nil {
logger.Println(err)
//m.TeeLogger.one.Notice(fmt.Sprintf("%s: " + err.Error(), ip))
Teelog.Print(fmt.Sprintf("%s: "+err.Error(), ip))
} else if sshCert, ok := pubKey.(*ssh.Certificate); !ok {
logger.Println("SSH public key is not a certificate")
//m.TeeLogger.one.Notice(fmt.Sprintf("%s: SSH public key is not a certificate"))
Teelog.Print(fmt.Sprintf("%s: SSH public key is not a certificate"))

} else {
switch len(sshCert.ValidPrincipals) {
case 0:
logger.Println(
"Received SSH certificate with no valid principals")
//m.TeeLogger.one.Notice(fmt.Sprintf("%s: Received SSH certificate with no valid principals", ip))
Teelog.Print(fmt.Sprintf("%s: Received SSH certificate with no valid principals", ip))
case 1:
logger.Printf("Received SSH certificate for: %s",
sshCert.ValidPrincipals[0])
//m.TeeLogger.one.Notice(fmt.Sprintf("%s: Received SSH certificate for: %s", ip, sshCert.ValidPrincipals[0]))
Teelog.Print(fmt.Sprintf("%s: Received SSH certificate for: %s", ip, sshCert.ValidPrincipals[0]))
default:
logger.Printf("Received SSH certificate for: %s",
sshCert.ValidPrincipals)
//m.TeeLogger.one.Notice(fmt.Sprintf("%s: Received SSH certificate for: %s", ip, sshCert.ValidPrincipals))
Teelog.Print(fmt.Sprintf("%s: Received SSH certificate for: %s", ip, sshCert.ValidPrincipals))
}
select { // Non-blocking notification.
case m.sshCertChannel <- sshCert:
Expand All @@ -345,7 +345,6 @@ func (m *Monitor) notify(event eventmon.EventV0, ip string, logger log.Logger, T
}
case eventmon.EventTypeWebLogin:
logger.Printf("Web login for: %s\n", event.Username)
//m.TeeLogger.one.Notice(fmt.Sprintf("%s: Web login for: %s", ip, event.Username))
select { // Non-blocking notification.
case m.webLoginChannel <- event.Username:
default:
Expand All @@ -360,14 +359,14 @@ func (m *Monitor) notify(event eventmon.EventV0, ip string, logger log.Logger, T
} else {
logger.Printf("Received X509 certificate for: %s\n",
x509Cert.Subject.CommonName)
//m.TeeLogger.one.Notice(fmt.Sprintf("%s: Received X509 certificate for: %s", ip, x509Cert.Subject.CommonName))
Teelog.Print(fmt.Sprintf("%s: Received X509 certificate for: %s", ip, x509Cert.Subject.CommonName))
select { // Non-blocking notification.
case m.x509CertChannel <- x509Cert:
default:
}
}
default:
logger.Printf("Invalid event type: %s\n", event.Type)
//m.TeeLogger.one.Notice(fmt.Sprintf("%s: Invalid event type: %s", ip, event.Type))
Teelog.Print(fmt.Sprintf("%s: Invalid event type: %s", ip, event.Type))
}
}
25 changes: 12 additions & 13 deletions eventmon/systeelogger/api.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package systeelogger

import (
"log/syslog"
//"github.com/Symantec/Dominator/lib/log"
"fmt"
"log/syslog"
)

const (
priority = syslog.LOG_AUTHPRIV
log_name = "keymaster"
)

type Logger struct{
type Logger struct {
One *syslog.Writer
}

Expand All @@ -23,18 +22,18 @@ func New() *Logger {
return &Logger{sysLog}
}

func (l *Logger) Fatal(v ...interface{}) {}
func (l *Logger) Fatalf(format string, v ...interface{}) {}
func (l *Logger) Fatalln(v ...interface{}) {}
func (l *Logger) Panic(v ...interface{}) {}
func (l *Logger) Panicf(format string, v ...interface{}) {}
func (l *Logger) Panicln(v ...interface{}) {}
func (l *Logger) Print(v ...interface{}) {
func (l *Logger) Fatal(v ...interface{}) {}
func (l *Logger) Fatalf(format string, v ...interface{}) {}
func (l *Logger) Fatalln(v ...interface{}) {}
func (l *Logger) Panic(v ...interface{}) {}
func (l *Logger) Panicf(format string, v ...interface{}) {}
func (l *Logger) Panicln(v ...interface{}) {}
func (l *Logger) Print(v ...interface{}) {
msg := fmt.Sprintln(v...)
l.One.Notice(msg)
}
func (l *Logger) Printf(format string, v ...interface{}) {}
func (l *Logger) Println(v ...interface{}) {}
func (l *Logger) Close() {
func (l *Logger) Printf(format string, v ...interface{}) {}
func (l *Logger) Println(v ...interface{}) {}
func (l *Logger) Close() {
l.One.Close()
}

0 comments on commit d292037

Please sign in to comment.