Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogInfo ¶
LogInfo contains parameters used to provide logging throughout a program.
func CreateLogFile ¶
CreateLogFile creates a log file in a directory named logs, which is a subdirectory of the given directory. The log file's name is the base name of the given directory with the extension .log.
Parameters:
logDir: A string representing the directory where the logs subdirectory should be created.
Returns:
LogInfo: A struct containing information about the log file, including its directory, file pointer, file name, and path.
error: An error if the log file or its parent directory cannot be created.
Example:
logDir := "/path/to/logDir" logName := "stuff.log" logInfo, err := logging.CreateLogFile(logDir, logName)
if err != nil {
fmt.Printf("failed to create log file: %v", err)
}
fmt.Printf("Log file created at: %s", logInfo.Path)