[SERVER-20172] Clean up newline chars in log messages Created: 28/Aug/15  Updated: 06/Dec/22  Resolved: 09/Nov/20

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Kevin Pulo Assignee: Backlog - Service Architecture
Resolution: Done Votes: 0
Labels: move-sec, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Service Arch
Operating System: ALL
Participants:

 Description   

The "setShardVersion failed!" log line has a needless newline in it; this should be changed to ":<space>", like the "setShardVersion success:" message above it. See SERVER-13069 for rationale.

src/mongo/s/version_manager.cpp:386

    LOG(1) << "       setShardVersion failed!\n" << result;

Verbose query planning logging makes use of newlines in log messages by necessity for readability purposes. This isn't a problem.

Additionally some log lines use "\n" as their terminator; these could be cleaned up to use endl instead:

$ ag 'LOG\(.*\\n'
db/exec/multi_plan.cpp
125:        LOG(5) << "Best plan errored out switching to backup\n";
143:        LOG(5) << "Best plan had a blocking stage, became unblocked\n";
253:    LOG(5) << "Winning solution:\n" << bestSolution->toString() << endl;
258:        LOG(5) << "Winner has blocking stage, looking for backup plan...\n";
261:                LOG(5) << "Candidate " << ix << " is backup child\n";
 
db/repl/master_slave.cpp
865:    LOG(2) << "sync_pullOpLog " << ns << " syncedTo:" << syncedTo.toStringLong() << '\n';
916:        LOG(2) << "tailing=true\n";
939:            LOG(2) << "tailing & no new activity\n";
975:        LOG(2) << "first op time received: " << nextOpTime.toString() << '\n';
977:            LOG(1) << "initial run\n";
 
db/storage/mmap_v1/mmap_v1_extent_manager.cpp
469:        LOG(n < 512 ? 1 : 0) << "warning: newExtent " << n << " scanned\n";
 
db/query/planner_analysis.cpp
693:        LOG(5) << "PROJECTION: Current plan is:\n" << solnRoot->toString() << endl;
699:            LOG(5) << "PROJECTION: claims to require doc adding fetch.\n";
710:            LOG(5) << "PROJECTION: requires fields\n";
 
db/query/query_planner.cpp
420:    LOG(5) << "Planner: solution constructed from the cache:\n" << soln->toString();
468:            LOG(5) << "Forcing a table scan due to hinted $natural\n";
787:    LOG(5) << "Planner: outputted " << out->size() << " indexed solutions.\n";
 
db/query/find.cpp
460:    LOG(5) << "getMore returned " << numResults << " results\n";
487:    LOG(5) << "Running query:\n" << cq->toString();
662:        LOG(5) << "Not caching executor but returning " << numResults << " results.\n";
 
s/version_manager.cpp
386:    LOG(1) << "       setShardVersion failed!\n" << result;
 
util/tcmalloc_server_status_section.cpp
69:    LOG(1) << "tcmallocPoolSize: " << tcmallocPoolSize << "\n";



 Comments   
Comment by Spencer Jackson [ 09/Nov/20 ]

Structured logging has rewritten all log lines in the codebase, and made it easier to interleave constant messages and variables.

Generated at Thu Feb 08 03:53:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.