sibojia / google-glog

Automatically exported from code.google.com/p/google-glog
Other
0 stars 0 forks source link

User name is not detected on Windows and set to 'invalid-user' #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. cd glog-0.2.1\src
2. cl /Iwindows /D "GOOGLE_GLOG_DLL_DECL=" /Gm /EHsc /RTC1 /MDd /W3 /nologo 
/ZI /TP main.cc logging.cc windows\port.cc raw_logging.cc utilities.cc 
vlog_is_on.cc
3. run 'run.cmd' (run.cmd and main.cc are attached)

What is the expected output? What do you see instead?

I expect to get a log file in the current directory named similar to this:

main..jago.log.INFO.20090710-004203.5680

where 'jago' is the current Windows user name, but I am getting the log 
file named:

main..invalid-user.log.INFO.20090710-004203.5680

What version of the product are you using? On what operating system?

glog-0.2.1
Windows XP SP3
Visual Studio 2008 SP1

Please provide any additional information below.

This patch fixes the problem:

--- utilities.cc        2009-04-10 11:25:14.000000000 +0400
+++ utilities.cc        2009-07-10 00:31:16.402625000 +0400
@@ -281,7 +281,11 @@
 }
 static void MyUserNameInitializer() {
   // TODO(hamaji): Probably this is not portable.
+#if defined(OS_WINDOWS)
+  const char* user = getenv("USERNAME");
+#else
   const char* user = getenv("USER");
+#endif
   if (user != NULL) {
     g_my_user_name = user;
   } else {

Original issue reported on code.google.com by ade...@gmail.com on 9 Jul 2009 at 8:47

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch! Sorry for the latency. I'd like to apply it to fix this 
issue.

Could you sign our Individual Contributor License Agreement, please?
We need to ask you to sign this to avoid any troubles. The process is
just submitting an HTML form, and it shouldn't take your time so much.

http://code.google.com/legal/individual-cla-v1.0.html

Please note that these forms do not transfer copyright: the
contributor retains her ownership in the work. The CLA just grants
Google a "perpetual, non-exclusive, royalty-free, etc..." right to use
the work, sublicense it, and so on.

Thanks!

Original comment by shinichi...@gmail.com on 27 Jul 2009 at 8:28

GoogleCodeExporter commented 9 years ago
I remember I had already signed that form for contributing to the Google Test 
but I 
have done again now to make it fresh.

Original comment by ade...@gmail.com on 29 Jul 2009 at 8:13

GoogleCodeExporter commented 9 years ago
Ah, I didn't notice that... Anyway, I checked this patch in. Thanks again for 
the 
patch!

http://code.google.com/p/google-glog/source/detail?r=64

Original comment by shinichi...@gmail.com on 29 Jul 2009 at 8:39