logfile 플래그 재 활성화 및 플래그가 꺼질경우 houston도 child proc의 로그파일을 생성하지 않음

This commit is contained in:
2024-07-08 15:09:21 +09:00
parent a2ef22d41a
commit 18d284a4ea

View File

@ -1,7 +1,6 @@
package logger
import (
"flag"
"fmt"
"io"
"log"
@ -10,10 +9,12 @@ import (
"runtime"
"runtime/debug"
"strings"
"repositories.action2quare.com/ayo/gocommon/flagx"
)
var stdlogger *log.Logger
var _ = flag.Bool("logfile", false, "")
var UseLogFile = flagx.Bool("logfile", false, "")
func init() {
binpath, _ := os.Executable()
@ -22,16 +23,7 @@ func init() {
var outWriter io.Writer
outWriter = os.Stdout
args := os.Args
useLogFile := false
for _, arg := range args {
if arg == "-logfile" {
useLogFile = true
break
}
}
if useLogFile {
if *UseLogFile {
ext := path.Ext(binname)
if len(ext) > 0 {
binname = binname[:len(binname)-len(ext)]