Skip to content

Commit

Permalink
Fix audit log file permission and use date suffix in name (#181) (#191)
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Aug 18, 2023
1 parent e4a4ae5 commit a4f381c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion states/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path"
"time"

"github.com/milvus-io/birdwatcher/configs"
"github.com/milvus-io/birdwatcher/states/etcd"
Expand Down Expand Up @@ -131,7 +132,8 @@ func getDryModeCmd(cli clientv3.KV, state *InstanceState, etcdState State) *cobr

func getInstanceState(cli clientv3.KV, instanceName, metaPath string, etcdState State, config *configs.Config) State {
var kv clientv3.KV
file, err := os.OpenFile("audit.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, os.ModeAppend)
name := fmt.Sprintf("audit_%s.log", time.Now().Format("2006_0102_150405"))
file, err := os.OpenFile(name, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Println("failed to open audit.log file!")
kv = cli
Expand Down

0 comments on commit a4f381c

Please sign in to comment.