You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
670 B
Go
36 lines
670 B
Go
package icslog
|
|
|
|
import (
|
|
"log"
|
|
"mybatch/icsconf"
|
|
"os"
|
|
"path/filepath"
|
|
"time"
|
|
)
|
|
|
|
var cfg icsconf.AppInfo
|
|
|
|
func init() {
|
|
cfg = icsconf.Getconfig()
|
|
}
|
|
|
|
func InitializeLogger() *log.Logger {
|
|
logDirectory := cfg.Directories.LOGDirectory
|
|
currentTime := time.Now().Format("20060102") // YYYY-MM-DD 형식
|
|
logFileName := "icsbc.log-" + currentTime
|
|
|
|
logFilePath := filepath.Join(logDirectory, logFileName)
|
|
|
|
file, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
logger := log.New(file, "", log.LstdFlags)
|
|
return logger
|
|
}
|
|
|
|
func LogMessage(logger *log.Logger, message string) {
|
|
logger.Println(message)
|
|
}
|