diff options
author | halyavin@google.com <halyavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-27 20:22:04 +0000 |
---|---|---|
committer | halyavin@google.com <halyavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-27 20:22:04 +0000 |
commit | 78f2fd9623e6711da7dc2f615bdcfccadd1b1efd (patch) | |
tree | 5094331fddc6abaa55aaee554ecb122a2b6ee1b6 /ppapi | |
parent | feba2ee2b9b440a05e369b3c93ff7cc9a1f6cf6c (diff) | |
download | chromium_src-78f2fd9623e6711da7dc2f615bdcfccadd1b1efd.zip chromium_src-78f2fd9623e6711da7dc2f615bdcfccadd1b1efd.tar.gz chromium_src-78f2fd9623e6711da7dc2f615bdcfccadd1b1efd.tar.bz2 |
Redirect NaCl plugin logs to different files for different processes.
Currently these logs are not useful because different renderer processes
overwrite each other logs.
TEST= launch chrome with --no-sandbox flag and NACL_PLUGIN_LOG variable
set to some path and NACL_PLUGIN_DEBUG set to 1. Observe different
log files for different render processes.
BUG= None
Review URL: https://codereview.chromium.org/212633002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/utility.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/utility.cc b/ppapi/native_client/src/trusted/plugin/utility.cc index 1458e18..d800424 100644 --- a/ppapi/native_client/src/trusted/plugin/utility.cc +++ b/ppapi/native_client/src/trusted/plugin/utility.cc @@ -8,6 +8,8 @@ #include <stdlib.h> #include <string.h> +#include "native_client/src/include/portability_io.h" +#include "native_client/src/include/portability_process.h" #include "ppapi/native_client/src/trusted/plugin/utility.h" namespace plugin { @@ -33,14 +35,26 @@ int NaClPluginPrintLog(const char *format, ...) { /* * Opens file where plugin log should be written. The file name is - * taken from NACL_PLUGIN_LOG environment variable. + * taken from NACL_PLUGIN_LOG environment variable and process pid. * If environment variable doesn't exist or file can't be opened, * the function returns stdout. */ FILE* NaClPluginLogFileEnv() { char* file = getenv("NACL_PLUGIN_LOG"); if (NULL != file) { - FILE* log_file = fopen(file, "w+"); + int pid = GETPID(); + /* + * 11 characters for pid, 5 for a glue string and 1 for null terminator. + */ + size_t filename_length = strlen(file) + 32; + char* filename = new char[filename_length]; + int ret = SNPRINTF(filename, filename_length, "%s.%d.log", file, pid); + if (ret <= 0 || static_cast<size_t>(ret) >= filename_length) { + delete[] filename; + return stdout; + } + FILE* log_file = fopen(filename, "w+"); + delete[] filename; if (NULL == log_file) { return stdout; } |