12345678910111213141516171819202122232425262728293031 |
- package authlogger
- import (
- "log"
- "net/http"
- "time"
- )
- /*
- AuthLogger
- Author: tobychui
- This module help log the login request and help the user to trace who is trying
- to break into their system.
- */
- type Logger struct {
- }
- //New Logger create a new logger object
- func NewLogger() *Logger {
- return &Logger{}
- }
- //Log the current authentication to record, Require the request object and login status
- func (l *Logger) LogAuth(r *http.Request, loginStatus bool) {
- username, _ := mv(r, "username", true)
- timestamp := time.Now().Unix()
- log.Println("Logger log (timestamp, username, login succeed)", timestamp, username, loginStatus)
- }
|