@@ -30,40 +30,41 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3030#include < string>
3131
3232namespace cppcore {
33-
34- static void appendDomain (const String &domain, String &logMsg) {
35- if (!domain.isEmpty ()) {
36- logMsg += ' (' ;
37- logMsg += domain;
38- logMsg += ' )' ;
39- }
40- }
41-
42- static ::std::string stripFilename (const ::std::string &filename) {
43- if (filename.empty ()) {
44- return filename;
33+ namespace {
34+ void appendDomain (const String &domain, String &logMsg) {
35+ if (!domain.isEmpty ()) {
36+ logMsg += ' (' ;
37+ logMsg += domain;
38+ logMsg += ' )' ;
39+ }
4540 }
46-
47- ::std::string::size_type pos = filename.find_last_of (" /" );
48- if (pos == ::std::string::npos) {
49- return filename;
41+
42+ ::std::string stripFilename (const ::std::string &filename) {
43+ if (filename.empty ()) {
44+ return filename;
45+ }
46+
47+ ::std::string::size_type pos = filename.find_last_of (" /" );
48+ if (pos == ::std::string::npos) {
49+ return filename;
50+ }
51+ const ::std::string strippedName = filename.substr (pos + 1 , filename.size () - pos - 1 );
52+
53+ return strippedName;
5054 }
51- const ::std::string strippedName = filename.substr (pos + 1 , filename.size () - pos - 1 );
52-
53- return strippedName;
54- }
55-
56- static void addTraceInfo (const String &file, int line, String &msg) {
57- if (Logger::getInstance ()->getVerboseMode () == Logger::VerboseMode::Trace) {
58- msg += String (" (" , 2 );
59- std::string stripped = stripFilename (file.c_str ());
60- msg += String (stripped.c_str (), stripped.size ());
61- msg += String (" , " , 2 );
62- std::stringstream ss;
63- ss << line;
64- std::string lineno = ss.str ();
65- msg += String (lineno.c_str (), lineno.size ());
66- msg += ' )' ;
55+
56+ void addTraceInfo (const String &file, int line, String &msg) {
57+ if (Logger::getInstance ()->getVerboseMode () == Logger::VerboseMode::Trace) {
58+ msg += String (" (" , 2 );
59+ std::string stripped = stripFilename (file.c_str ());
60+ msg += String (stripped.c_str (), stripped.size ());
61+ msg += String (" , " , 2 );
62+ std::stringstream ss;
63+ ss << line;
64+ std::string lineno = ss.str ();
65+ msg += String (lineno.c_str (), lineno.size ());
66+ msg += ' )' ;
67+ }
6768 }
6869}
6970
@@ -82,7 +83,7 @@ bool AbstractLogStream::isActive() const {
8283Logger *Logger::sLogger = nullptr ;
8384
8485Logger *Logger::create () {
85- if (nullptr == sLogger ) {
86+ if (sLogger == nullptr ) {
8687 sLogger = new Logger;
8788 }
8889
@@ -98,7 +99,7 @@ void Logger::set(Logger *logger) {
9899}
99100
100101Logger *Logger::getInstance () {
101- if (nullptr == sLogger ) {
102+ if (sLogger == nullptr ) {
102103 static_cast <void >(create ());
103104 }
104105
@@ -189,8 +190,7 @@ void Logger::print(const String &msg, PrintMode mode) {
189190 }
190191 }
191192
192- if (msg.size () > 8 ) {
193- if (msg[6 ] == ' =' && msg[7 ] == ' >' ) {
193+ if (msg.size () > 8 && msg[6 ] == ' =' && msg[7 ] == ' >' ) {
194194 mIntention += 2 ;
195195 }
196196 }
@@ -231,7 +231,7 @@ void Logger::registerLogStream(AbstractLogStream *pLogStream) {
231231 mLogStreams .add (pLogStream);
232232}
233233
234- void Logger::unregisterLogStream (AbstractLogStream *logStream) {
234+ void Logger::unregisterLogStream (const AbstractLogStream *logStream) {
235235 if (nullptr == logStream) {
236236 return ;
237237 }
@@ -254,8 +254,8 @@ Logger::~Logger() {
254254 }
255255}
256256
257- String Logger::getDateTime () {
258- static const uint32_t Space = 2 ;
257+ String Logger::getDateTime () const {
258+ static constexpr uint32_t Space = 2 ;
259259 DateTime currentDateTime;
260260 std::stringstream stream;
261261 stream.fill (' 0' );
0 commit comments