Skip to content

Commit

Permalink
Result of merging features/dev -r7759:7824 to trunk.
Browse files Browse the repository at this point in the history
Dont crash at shutdown.

Init logger gPid locally so Logger can be used in other programs besides OpenBTS, and shorten the log format.
  • Loading branch information
pat-thompson authored and iedemam committed Mar 31, 2014
1 parent b214734 commit c17e42b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down Expand Up @@ -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:
Expand Down
10 changes: 2 additions & 8 deletions Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); };
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Reporting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
3 changes: 3 additions & 0 deletions Reporting.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ReportingTable {


public:
bool mReportRunning;

/**
Open the database connection;
Expand Down Expand Up @@ -91,6 +92,8 @@ class ReportingTable {

/** Commit outstanding report updates to the database */
bool commit();

void reportShutdown() { mReportRunning = false; }
};

/** Periodically triggers ReportingTable::commit(). */
Expand Down

0 comments on commit c17e42b

Please sign in to comment.