Permalink
Browse files

Added --log-level option. Removed new lines from debugLog() calls.

  • Loading branch information...
1 parent a045501 commit 613157ef7e45643cb00655a7eb10ca9146bc53e9 @acaudwell committed Jan 23, 2012
Showing with 30 additions and 11 deletions.
  1. +1 −1 src/core
  2. +2 −2 src/dirnode.cpp
  3. +3 −3 src/gource.cpp
  4. +18 −3 src/gource_settings.cpp
  5. +2 −0 src/gource_settings.h
  6. +4 −2 src/main.cpp
2 src/core
@@ -1 +1 @@
-Subproject commit 65d4826480a3682e9824379dd6ed953f1ede9668
+Subproject commit 8ea748d589e1b6e935b104a505fafec3692d617a
View
4 src/dirnode.cpp
@@ -386,7 +386,7 @@ bool RDirNode::addFile(RFile* f) {
//simply change path of node and add this to it
if( parent==0 && abspath == "/"
&& f->path.compare(abspath) != 0 && noFiles() && noDirs()) {
- debugLog("modifying root path to %s\n", f->path.c_str());
+ debugLog("modifying root path to %s", f->path.c_str());
changePath(f->path);
}
@@ -704,7 +704,7 @@ void RDirNode::debug(int indent) const{
std::string indentstr;
while(indentstr.size() < indent) indentstr += " ";
- debugLog("%s%s\n", indentstr.c_str(), abspath.c_str());
+ debugLog("%s%s", indentstr.c_str(), abspath.c_str());
for(std::list<RDirNode*>::const_iterator it = children.begin(); it != children.end(); it++) {
RDirNode* node = (*it);
View
6 src/gource.cpp
@@ -207,7 +207,7 @@ bool Gource::findRepository(boost::filesystem::path& dir, std::string& log_forma
}
RCommitLog* Gource::determineFormat(std::string logfile) {
- debugLog("determineFormat(%s)\n", logfile.c_str());
+ debugLog("determineFormat(%s)", logfile.c_str());
RCommitLog* clog = 0;
@@ -233,7 +233,7 @@ RCommitLog* Gource::determineFormat(std::string logfile) {
//we've been told what format to use
if(log_format.size() > 0) {
- debugLog("log-format = %s\n", log_format.c_str());
+ debugLog("log-format = %s", log_format.c_str());
if(log_format == "git") {
clog = new GitCommitLog(logfile);
@@ -1068,7 +1068,7 @@ RFile* Gource::addFile(const RCommitFile& cf) {
file_key.inc(file);
while(root->getParent() != 0) {
- debugLog("parent changed to %s\n", root->getPath().c_str());
+ debugLog("parent changed to %s", root->getPath().c_str());
root = root->getParent();
}
View
21 src/gource_settings.cpp
@@ -182,6 +182,7 @@ GourceSettings::GourceSettings() {
conf_sections["load-config"] = "command-line";
conf_sections["save-config"] = "command-line";
conf_sections["output-custom-log"] = "command-line";
+ conf_sections["log-level"] = "command-line";
//boolean args
arg_types["help"] = "bool";
@@ -239,6 +240,7 @@ GourceSettings::GourceSettings() {
arg_types["follow-user"] = "multi-value";
arg_types["highlight-user"] = "multi-value";
+ arg_types["log-level"] = "string";
arg_types["background-image"] = "string";
arg_types["logo"] = "string";
arg_types["logo-offset"] = "string";
@@ -355,6 +357,8 @@ void GourceSettings::setGourceDefaults() {
gStringHashSeed = 31;
+ log_level = LOG_LEVEL_ERROR;
+
//delete file filters
for(std::vector<Regex*>::iterator it = file_filters.begin(); it != file_filters.end(); it++) {
delete (*it);
@@ -430,6 +434,20 @@ void GourceSettings::commandLineOption(const std::string& name, const std::strin
return;
}
+ if(name == "log-level") {
+
+ if(value == "warn") {
+ log_level = LOG_LEVEL_WARN;
+ } else if(value == "debug") {
+ log_level = LOG_LEVEL_DEBUG;
+ } else if(value == "info") {
+ log_level = LOG_LEVEL_INFO;
+ } else if(value == "error") {
+ log_level = LOG_LEVEL_ERROR;
+ }
+ return;
+ }
+
std::string invalid_error = std::string("invalid ") + name + std::string(" value");
throw ConfFileException(invalid_error, "", 0);
}
@@ -1098,9 +1116,6 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
}
}
-
-
-
//validate path
if(gource_settings->hasValue("path")) {
path = gource_settings->getString("path");
View
2 src/gource_settings.h
@@ -133,6 +133,8 @@ class GourceSettings : public SDLAppSettings {
TextureResource* file_graphic;
+ int log_level;
+
GourceSettings();
void setGourceDefaults();
View
6 src/main.cpp
@@ -60,6 +60,9 @@ int main(int argc, char *argv[]) {
}
}
+ //set log level
+ logger->setLevel(gGourceSettings.log_level);
+
//load config
if(!gGourceSettings.load_config.empty()) {
conf.clear();
@@ -118,8 +121,7 @@ int main(int argc, char *argv[]) {
//enable vsync
display.enableVsync(gGourceSettings.vsync);
-
-
+
//allow resizing window if we are not recording
if(gGourceSettings.output_ppm_filename.empty()) {
display.enableResize(true);

0 comments on commit 613157e

Please sign in to comment.