implement and use first logging event (ReadFile)
This commit is contained in:
@@ -2,6 +2,26 @@ package logging
|
|||||||
|
|
||||||
import "log"
|
import "log"
|
||||||
|
|
||||||
|
type EventType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
ReadFile EventType = iota
|
||||||
|
)
|
||||||
|
|
||||||
func Info(message string) {
|
func Info(message string) {
|
||||||
log.Print(message)
|
log.Print(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Infof(message string, vars ...any) {
|
||||||
|
log.Printf(message, vars...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Event(eventType EventType, eventData ...any) {
|
||||||
|
switch eventType {
|
||||||
|
case ReadFile:
|
||||||
|
{
|
||||||
|
log.Printf("Reading file %s", eventData[0])
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -307,12 +307,19 @@ func cleanupSessions() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ReadFile(path string) ([]byte, error) {
|
||||||
|
logging.Event(logging.ReadFile, "static/blank_profile.jpg")
|
||||||
|
data, err := os.ReadFile(path)
|
||||||
|
logging.Infof("Successfully read file at %s", path)
|
||||||
|
return data, err
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logging.Info("Starting the server")
|
logging.Info("Starting the server")
|
||||||
|
|
||||||
var err error = nil
|
var err error = nil
|
||||||
|
|
||||||
blankPhotoData, err = os.ReadFile("static/blank_profile.jpg")
|
blankPhotoData, err = ReadFile("static/blank_profile.jpg")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Could not load blank profile image")
|
log.Fatal("Could not load blank profile image")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user