@@ -847,11 +847,19 @@ func OverrideFilePathsInFlagSet(t *test_suite.TestConfig, GCSFuseTempDirPath str
847847
848848func ParseLogFileFromFlags (flags []string ) string {
849849 for _ , flagStr := range flags {
850+ flagStr = strings .ReplaceAll (flagStr , "," , " " )
850851 parts := strings .Fields (flagStr )
851852 for _ , part := range parts {
852853 if strings .HasPrefix (part , "--log-file=" ) {
853- // Get just the filename from the path
854- return path .Base (strings .TrimPrefix (part , "--log-file=" ))
854+ logPath := strings .TrimPrefix (part , "--log-file=" )
855+ if logPath == "" {
856+ continue
857+ }
858+ fileName := path .Base (logPath )
859+ if ! strings .HasSuffix (fileName , ".log" ) {
860+ fileName += ".log"
861+ }
862+ return fileName
855863 }
856864 }
857865 }
@@ -861,14 +869,25 @@ func ParseLogFileFromFlags(flags []string) string {
861869func SetUpLogFilePath (flags []string , GKETempDir string , OldGKElogFilePath string , cfg * test_suite.TestConfig ) {
862870 var logFilePath string
863871 parsedLogFileName := ParseLogFileFromFlags (flags )
864- if cfg .GKEMountedDirectory != "" { // GKE path
865- logFilePath = path .Join (GKETempDir , parsedLogFileName ) + ".log"
872+
873+ // Infer log filename directly from the parsed config block.
874+ if parsedLogFileName == "" && cfg != nil && len (cfg .Configs ) > 0 {
875+ parsedLogFileName = ParseLogFileFromFlags (cfg .Configs [0 ].Flags )
876+ }
877+
878+ // Default logFile name.
879+ if parsedLogFileName == "" {
880+ parsedLogFileName = "gcsfuse-tmp.log"
881+ }
882+
883+ if cfg != nil && cfg .GKEMountedDirectory != "" { // GKE path
884+ logFilePath = path .Join (GKETempDir , parsedLogFileName )
866885 if ConfigFile () == "" {
867886 // TODO: clean this up when GKE test migration completes.
868887 logFilePath = OldGKElogFilePath
869888 }
870889 } else {
871- logFilePath = path .Join (TestDir (), GKETempDir , parsedLogFileName ) + ".log"
890+ logFilePath = path .Join (TestDir (), GKETempDir , parsedLogFileName )
872891 }
873892 cfg .LogFile = logFilePath
874893 SetLogFile (logFilePath )
0 commit comments