Skip to content

Commit

Permalink
docs: add documentation for Log function in logger package
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianoflorentino committed Nov 10, 2024
1 parent 450bc7d commit 2a513fe
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/logger/log.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
Package logger provides a method to log messages to a file and print them to the console
- Log: writes a log message to a file and prints it to the console
*/
package logger

import (
Expand All @@ -6,6 +10,13 @@ import (
"os"
)

// Log writes a log message to a file and prints it to the console
// - format: format of the log message
// - args: arguments to be formatted
//
// The method opens a file in the log directory and writes the log message
// If an error occurs while opening the file, the method logs an error message
// and exits the program
func Log(format string, args ...any) {
file, err := os.OpenFile("log/"+os.Getenv("GOENV")+".log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
Expand Down

0 comments on commit 2a513fe

Please sign in to comment.