@@ -48,7 +48,7 @@ import (
4848//
4949// $ go test -v --use-default-kcp-server
5050func main () {
51- flag .String ("log-file -path" , ".kcp/kcp.log " , "Path to the log file " )
51+ logDirPath := flag .String ("log-dir -path" , "" , "Directory for log files. If empty, .kcp is used. " )
5252 quiet := flag .Bool ("quiet" , false , "Suppress output of the subprocesses" )
5353
5454 // split flags into --shard-* and everything else (generic). The former are
@@ -67,7 +67,7 @@ func main() {
6767 }
6868 flag .CommandLine .Parse (genericFlags ) //nolint:errcheck
6969
70- if err := start (shardFlags , * quiet ); err != nil {
70+ if err := start (shardFlags , * logDirPath , * quiet ); err != nil {
7171 var exitErr * exec.ExitError
7272 if errors .As (err , & exitErr ) {
7373 os .Exit (exitErr .ExitCode ())
@@ -77,7 +77,7 @@ func main() {
7777 }
7878}
7979
80- func start (shardFlags []string , quiet bool ) error {
80+ func start (shardFlags []string , logDirPath string , quiet bool ) error {
8181 // We use a shutdown context to know that it's time to gather metrics, before stopping the shard
8282 shutdownCtx , shutdownCancel := context .WithCancel (genericapiserver .SetupSignalContext ())
8383 defer shutdownCancel ()
@@ -98,7 +98,11 @@ func start(shardFlags []string, quiet bool) error {
9898 return fmt .Errorf ("failed to create client-ca: %w" , err )
9999 }
100100
101- logFilePath := flag .Lookup ("log-file-path" ).Value .String ()
101+ logFilePath := filepath .Join (".kcp" , "kcp.log" )
102+ if logDirPath != "" {
103+ logFilePath = filepath .Join (logDirPath , "kcp.log" )
104+ }
105+
102106 s := shard .NewShard (
103107 "kcp" ,
104108 ".kcp" ,
0 commit comments