Bug 132346

Summary: For DARWIN platforms, use system temporary directory for DataLog output
Product: WebKit Reporter: Michael Saboff <msaboff>
Component: JavaScriptCoreAssignee: Michael Saboff <msaboff>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cmarcelo, commit-queue
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Work in Progress
none
Patch ggaren: review+

Description Michael Saboff 2014-04-29 11:22:09 PDT
Provide means to use the system defined temporary directory.
Comment 1 Michael Saboff 2014-04-29 11:23:08 PDT
Created attachment 230393 [details]
Work in Progress
Comment 2 Michael Saboff 2014-04-29 11:54:44 PDT
Created attachment 230395 [details]
Patch
Comment 3 Geoffrey Garen 2014-04-29 12:46:53 PDT
Comment on attachment 230395 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=230395&action=review

> Source/WTF/ChangeLog:8
> +        Added code to call confstr() to access the process' temporary directory to use that

"process's" -- there's only one.

> Source/WTF/wtf/DataLog.cpp:84
> +    size_t lastComponentLength = strlen(logBasename) + 10;
> +    size_t dirnameLength = confstr(_CS_DARWIN_USER_TEMP_DIR, filenameBuffer, 1024);
> +    if ((dirnameLength + lastComponentLength + 10) < maxPathLength) {
> +        strncat(filenameBuffer, logBasename, maxPathLength - dirnameLength);
> +        filename = filenameBuffer;
> +    }

Why + 10?

> Source/WTF/wtf/DataLog.cpp:106
>          if (!file)
> -            fprintf(stderr, "Warning: Could not open log file %s for writing.\n", actualFilename);
> +            WTFLogAlways("Warning: Could not open log file %s for writing.\n", actualFilename);
> +#if DATA_LOG_TO_DARWIN_TEMP_DIR
> +        else
> +            WTFLogAlways("*** Logging to \"%s\" ***\n", actualFilename);
> +#endif

Better to say "if (file) / else" rather than "if (!file) / else".
Comment 4 Michael Saboff 2014-04-29 12:59:45 PDT
Comment on attachment 230395 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=230395&action=review

>> Source/WTF/ChangeLog:8
>> +        Added code to call confstr() to access the process' temporary directory to use that
> 
> "process's" -- there's only one.

"process'" is a valid possessive form of process.

>> Source/WTF/wtf/DataLog.cpp:84
>> +    }
> 
> Why + 10?

For the .<pid>.txt, with an up to 5 digit pid, added below.  I'll recode without the constant.

>> Source/WTF/wtf/DataLog.cpp:106
>> +#endif
> 
> Better to say "if (file) / else" rather than "if (!file) / else".

I'll make the change.
Comment 5 Michael Saboff 2014-04-29 13:29:18 PDT
Committed r167953: <http://trac.webkit.org/changeset/167953>