Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
C7C8 committed May 16, 2015
2 parents ecf7b05 + d0d58f6 commit da8cd08
Showing 42 changed files with 908 additions and 1,254 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -112,3 +112,4 @@ Temporary Items
.apdisk
sysProps.xml
*.rej
docs/
Empty file removed .gitmodules
Empty file.
18 changes: 0 additions & 18 deletions README.md

This file was deleted.

103 changes: 0 additions & 103 deletions iomap.txt

This file was deleted.

2 changes: 1 addition & 1 deletion lib/Logger.cpp
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ namespace Hydra
}

stringstream logEntry;
logEntry << "[" << timeInfo->tm_hour << ":" << timeInfo->tm_min << ":" << timeInfo->tm_sec << "] ";
logEntry << "[" << timeInfo->tm_hour << ":" << timeInfo->tm_min << ":" << timeInfo->tm_sec << "]\t";
logEntry << flagText;
logEntry << message;
logBuffer.push_back(logEntry.str());
32 changes: 18 additions & 14 deletions lib/Logger.h
Original file line number Diff line number Diff line change
@@ -13,31 +13,35 @@ using std::vector;
using std::ofstream;
using std::stringstream;

//Logger files were ripped out of a game dev library. Some things here (such as flags) are customized more for game dev than for robotics.
//Note that as the roboRIO is Linux-based (or something really close) a "/" needs to be at the beginning of the filename in order to log anything.
namespace Hydra
{
#define MAX_LOGBUFFER_ENTRIES 10
#define MAX_LOGBUFFER_ENTRIES 10 //How many entries the log buffer stores before outputting all entries to a file. Change this to 0 for unstable (i.e. can crash) environments.

enum logFlag {error, hydsys, info, resource};
class Log
enum logFlag {error, hydsys, info, resource}; //All possible flags that could be used. Default is hydsys.
class Log
{
public:
Log(string newName, string newFilename);
void log(string message, logFlag flag = hydsys); //!< Writes a message (with timestamp) to the log with the specified flag
void flushBuffer();
public:
Log(string newName, string newFilename); //!< Creates a new log with this name at this filename. Do NOT append .txt to the filename, it does it automatically
void log(string message, logFlag flag = hydsys); //!< Writes a message (with timestamp) to the log with the specified flag
void flushBuffer(); //!< Forces the contents of the buffer to output to file.
private:
vector<string> logBuffer;
string filename;
vector<string> logBuffer;
string filename;
string name;
friend class Logger;
};
class Logger

//Logger class automatically creates its own sysLog log upon creation.
class Logger
{
public:
friend class Log;
void log(string message = "Default log output", logFlag flag = hydsys, string name = "sysLog"); //!< Logs something in the logger of the given name
void newLog(string name = "sysLog", string filename = "/sysLog"); //!< Creates a new log with the specified name and filename
Log* getLog(string name); //!< Returns a pointer to the log with the specified name.
void flushLogBuffers(); //!< Manually flushes all log buffers.
void log(string message = "Default log output", logFlag flag = hydsys, string name = "sysLog"); //!< Logs something in the logger of the given name
void newLog(string name = "sysLog", string filename = "/sysLog"); //!< Creates a new log with the specified name and filename
Log* getLog(string name); //!< Returns a pointer to the log with the specified name. If no such log exists, returns nullptr.
void flushLogBuffers(); //!< Manually flushes all log buffers.
static Logger* getInstance();
private:
static Logger* instance;
Loading

0 comments on commit da8cd08

Please sign in to comment.