Skip to content

Commit

Permalink
Improve code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-webb committed Jul 23, 2024
1 parent d29d30a commit 86a6661
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
37 changes: 9 additions & 28 deletions src/main/cpp/loggingevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,16 @@ struct LoggingEvent::LoggingEventPrivate
}

/**
* The logger of the logging event.
* The name of the logger used to make the logging request
**/
LogString logger;

/** level of logging event. */
/** severity level of logging event. */
LevelPtr level;

#if LOG4CXX_ABI_VERSION <= 15
/** The nested diagnostic context (NDC) of logging event. */
mutable LogString* ndc{NULL};

/** The mapped diagnostic context (MDC) of logging event. */
mutable MDC::Map* mdcCopy{NULL};
#endif

Expand All @@ -115,52 +113,35 @@ struct LoggingEvent::LoggingEventPrivate
std::map<LogString, LogString>* properties{NULL};

#if LOG4CXX_ABI_VERSION <= 15
/** Have we tried to do an NDC lookup? If we did, there is no need
* to do it again. Note that its value is always false when
* serialized. Thus, a receiving SocketNode will never use it's own
* (incorrect) NDC. See also writeObject method.
*/
mutable bool ndcLookupRequired{false};

/**
* Have we tried to do an MDC lookup? If we did, there is no need to do it
* again. Note that its value is always false when serialized. See also
* the getMDC and getMDCCopy methods.
*/
mutable bool mdcCopyLookupRequired{false};
#endif

/** The application supplied message of logging event. */
/** The application supplied message. */
LogString message;


/** The number of microseconds elapsed from 01.01.1970 until logging event
was created. */
/** The number of microseconds elapsed since 1970-01-01
* at the time this logging event was created.
*/
log4cxx_time_t timeStamp;

/** The is the location where this log statement was written. */
/** The source code location where the logging request was made. */
const spi::LocationInfo locationInfo;


#if LOG4CXX_ABI_VERSION <= 15
/** The identifier of thread in which this logging event
was generated.
*/
const LogString& threadName;

/**
* The user-specified name of the thread(on a per-platform basis).
* This is set using a method such as pthread_setname_np on POSIX
* systems or SetThreadDescription on Windows.
*/
const LogString& threadUserName;
#endif

std::chrono::time_point<std::chrono::system_clock> chronoTimeStamp;

/**
* This ensures the above string references remain valid
* for the lifetime of this LoggingEvent (i.e. even after thread termination).
* Thread names that remain valid for the lifetime of this LoggingEvent
* (i.e. even after thread termination).
*/
ThreadSpecificData::NamePairPtr pNames;

Expand Down
7 changes: 7 additions & 0 deletions src/main/cpp/threadspecificdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ struct ThreadSpecificData::ThreadSpecificDataPrivate{
void setThreadUserName();
};

/* Generate an identifier for the current thread
*/
void ThreadSpecificData::ThreadSpecificDataPrivate::setThreadIdName()
{
#if LOG4CXX_HAS_PTHREAD_SELF && !(defined(_WIN32) && defined(_LIBCPP_VERSION))
Expand All @@ -81,6 +83,11 @@ void ThreadSpecificData::ThreadSpecificDataPrivate::setThreadIdName()
#endif
}

/*
* Get the user-specified name of the current thread (on a per-platform basis).
* This is set using a method such as pthread_setname_np on POSIX
* systems or SetThreadDescription on Windows.
*/
void ThreadSpecificData::ThreadSpecificDataPrivate::setThreadUserName()
{
#if LOG4CXX_HAS_PTHREAD_GETNAME && !(defined(_WIN32) && defined(_LIBCPP_VERSION))
Expand Down

0 comments on commit 86a6661

Please sign in to comment.