[SERVER-6777] Eliminate all direct use of cout/stdout and cerr/stderr Created: 16/Aug/12 Updated: 08/Sep/20 Resolved: 08/Sep/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Logging |
| Affects Version/s: | None |
| Fix Version/s: | 4.7.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Tad Marshall | Assignee: | Adam Cooper (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | Windows, community-team, neweng, platforms-re-triaged | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows, running as a service (mongod and mongos) |
||
| Issue Links: |
|
||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||
| Operating System: | Windows | ||||||||||||||||||||||||
| Sprint: | Server 2.7.5, Server 2.7.6, Security 2020-05-04, Security 2020-05-18, Security 2020-06-01, Security 2020-08-24, Security 2020-09-07, Security 2020-09-21 | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Description |
|
cout/stdout and cerr/stderr do not work when running as a Windows service We use cout and cerr in assorted places in the code, and we use the C/C++ function dup2() to redirect file handles 1 and 2 (stdout and stderr) to the log file so that statements like "cout << "message" << endl;" will send text to the screen or to a log file if --logpath is set. This works fine in Windows when running in a console window. It doesn't work when mongod.exe or mongos.exe is running as a service in Windows. Text sent to cout or cerr (or stdout or stderr) goes nowhere and does not appear in the log file. The dup2() API does not return an error ... it just doesn't do what we want it to do. This means that some output will not be logged when running as a Windows Service. We may need to audit the code to identify places where we are relying on redirection of standard file handles to log output and change them to use another mechanism (like log()). |
| Comments |
| Comment by Githook User [ 08/Sep/20 ] |
|
Author: {'name': 'Adam Cooper', 'email': 'adam.cooper@mongodb.com', 'username': 'super-cooper'}Message: |
| Comment by Sara Golemon [ 01/Jun/20 ] |
|
While there are a number of locations where cout/cerr are used in SERVER, the majority of these are by necessity as they are not log statements and relate to human interactivity when attempting to start the server (or shell). The one case I ran into where we really shouldn't be using cout/cerr is mongo/util/processinfo_osx.cpp , however as the name implies this file related to OSX only and not Windows. I'm going to downgrade this to 'Minor' and move it to the backlog so that we don't lose track of it. |