Result of merging features/dev -r7759:7824 to trunk.

Dont crash at shutdown.

Init logger gPid locally so Logger can be used in other programs besides OpenBTS, and shorten the log format.
This commit is contained in:
pat.thompson 2014-03-31 12:15:14 +02:00 committed by Michael Iedema
parent b21473440f
commit c17e42bd8e
4 changed files with 9 additions and 9 deletions

View File

@ -47,6 +47,7 @@ std::list<std::string> alarmsList;
void addAlarm(const std::string&);
//@}
// (pat 3-2014) Note that the logger is used by multiple programs.
pid_t gPid = 0;
@ -286,6 +287,7 @@ void gLogInit(const char* name, const char* level, int facility)
if (level) {
gConfig.set("Log.Level",level);
}
gPid = getpid();
// Pat added, tired of the syslog facility.
// Both the transceiver and OpenBTS use this same facility, but only OpenBTS/OpenNodeB may use this log file:

View File

@ -44,10 +44,6 @@
#include <string>
#include <assert.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/unistd.h>
#include "Threads.h"
// We cannot include Utils.h because it includes Logger.h, so just declare timestr() here.
// If timestr decl is changed G++ will whine when Utils.h is included.
namespace Utils { const std::string timestr(); };
@ -57,11 +53,9 @@ namespace Utils { const std::string timestr(); };
#endif // !defined(gettid)
extern pid_t gPid;
#define _LOG(level) \
Log(LOG_##level).get() << "pid(" << gPid << "), " \
<< "tid(" << gettid() << ") " \
<< Utils::timestr(21, true) << " " __FILE__ ":" << __LINE__ << ":" << __FUNCTION__ << ": "
Log(LOG_##level).get() <<gPid <<":"<<gettid() \
<< Utils::timestr(100,true) << " " __FILE__ ":" << __LINE__ << ":" << __FUNCTION__ << ": "
// (pat) If you '#define LOG_GROUP groupname' before including Logger.h, then you can set Log.Level.groupname as well as Log.Level.filename.
#ifdef LOG_GROUP

View File

@ -208,7 +208,8 @@ bool ReportingTable::commit()
extern ReportingTable gReports;
void* reportingBatchCommitter(void*)
{
while (true) {
gReports.mReportRunning = true;
while (gReports.mReportRunning) {
sleep(10);
gReports.commit();
}

View File

@ -52,6 +52,7 @@ class ReportingTable {
public:
bool mReportRunning;
/**
Open the database connection;
@ -91,6 +92,8 @@ class ReportingTable {
/** Commit outstanding report updates to the database */
bool commit();
void reportShutdown() { mReportRunning = false; }
};
/** Periodically triggers ReportingTable::commit(). */