Permalink
Browse files

o Only if -D is given, the debug toggle is active in the UI.

  • Loading branch information...
hzeller committed Sep 18, 2012
1 parent 3e883b7 commit 8c7e5c11a9175a264ec77d150d5b8b84fb18950b
Showing with 24 additions and 16 deletions.
  1. +3 −2 README
  2. +5 −6 folve-filesystem.cc
  3. +4 −1 folve-filesystem.h
  4. +4 −2 folve-main.cc
  5. +8 −5 status-server.cc
View
5 README
@@ -94,10 +94,11 @@ General usage:
usage: ./folve [options] <original-dir> <mount-point>
Options: (in sequence of usefulness)
-c <cfg-dir> : Convolver configuration directory.
- You can supply this option multiple times;
+ You can supply this option multiple times:
you'll get a drop-down select on the HTTP status page.
-p <port> : Port to run the HTTP status server on.
- -D : Moderate volume Folve debug messages.
+ -D : Moderate volume Folve debug messages to syslog.
+ Can then also be toggled in the UI.
-f : Operate in foreground; useful for debugging.
-o <mnt-opt> : other generic mount parameters passed to fuse.
-d : High volume fuse debug log. Implies -f.
View
@@ -500,6 +500,11 @@ class SndFileHandler :
};
} // namespace
+FolveFilesystem::FolveFilesystem()
+ : current_cfg_index_(0), debug_ui_enabled_(false),
+ open_file_cache_(3), total_file_openings_(0), total_file_reopen_(0) {
+ config_dirs_.push_back(""); // The first config is special: empty.
+}
FileHandler *FolveFilesystem::CreateFromDescriptor(int filedes,
int cfg_idx,
@@ -563,12 +568,6 @@ void FolveFilesystem::Close(const char *fs_path, const FileHandler *handler) {
open_file_cache_.Unpin(cache_key);
}
-FolveFilesystem::FolveFilesystem()
- : current_cfg_index_(0),
- open_file_cache_(3), total_file_openings_(0), total_file_reopen_(0) {
- config_dirs_.push_back(""); // The first config is special: empty.
-}
-
void FolveFilesystem::SwitchCurrentConfigIndex(int i) {
if (i < 0 || i >= (int) config_dirs_.size())
return;
View
@@ -72,6 +72,9 @@ class FolveFilesystem {
void SetDebugMode(bool b);
bool IsDebugMode() const;
+ void set_debug_ui_enabled(bool b) { debug_ui_enabled_ = b; }
+ bool is_debug_ui_enabled() const { return debug_ui_enabled_; }
+
// Some stats.
int total_file_openings() { return total_file_openings_; }
int total_file_reopen() { return total_file_reopen_; }
@@ -87,7 +90,7 @@ class FolveFilesystem {
std::string underlying_dir_;
std::vector<std::string> config_dirs_;
int current_cfg_index_;
-
+ bool debug_ui_enabled_;
FileHandlerCache open_file_cache_;
int total_file_openings_;
int total_file_reopen_;
View
@@ -208,11 +208,12 @@ static int usage(const char *prg) {
printf("usage: %s [options] <original-dir> <mount-point>\n", prg);
printf("Options: (in sequence of usefulness)\n"
"\t-c <cfg-dir> : Convolver configuration directory.\n"
- "\t You can supply this option multiple times;\n"
+ "\t You can supply this option multiple times:\n"
"\t you'll get a drop-down select on the HTTP "
"status page.\n"
"\t-p <port> : Port to run the HTTP status server on.\n"
- "\t-D : Moderate volume Folve debug messages.\n"
+ "\t-D : Moderate volume Folve debug messages to syslog.\n"
+ "\t Can then also be toggled in the UI.\n"
"\t-f : Operate in foreground; useful for debugging.\n"
"\t-o <mnt-opt> : other generic mount parameters passed to fuse.\n"
"\t-d : High volume fuse debug log. Implies -f.\n");
@@ -253,6 +254,7 @@ int FolveOptionHandling(void *data, const char *arg, int key,
rt->fs->add_config_dir(arg + 2); // strip "-c"
return 0;
case FOLVE_OPT_DEBUG:
+ rt->fs->set_debug_ui_enabled(true);
rt->fs->SetDebugMode(true);
return 0;
}
View
@@ -99,6 +99,7 @@ void StatusServer::SetFilter(const char *filter) {
}
void StatusServer::SetDebug(const char *dbg) {
+ if (!filesystem_->is_debug_ui_enabled()) return;
filesystem_->SetDebugMode(dbg != NULL && *dbg == '1');
}
@@ -189,11 +190,13 @@ void StatusServer::AppendFilterOptions(std::string *result) {
result->append(" <span style='font-size:small;'>Affects re- or newly opened "
"files.</span>");
}
- Appendf(result, "<span style='float:right;font-size:small;'>"
- "<label for='dbg_sel'>Folve debug to syslog</label>"
- "<input id='dbg_sel' onchange='this.form.submit();' "
- "type='checkbox' name='d' value='1'%s/></span>",
- filesystem_->IsDebugMode() ? " checked" : "");
+ if (filesystem_->is_debug_ui_enabled()) {
+ Appendf(result, "<span style='float:right;font-size:small;'>"
+ "<label for='dbg_sel'>Folve debug to syslog</label>"
+ "<input id='dbg_sel' onchange='this.form.submit();' "
+ "type='checkbox' name='d' value='1'%s/></span>",
+ filesystem_->IsDebugMode() ? " checked" : "");
+ }
result->append("</form>");
}

0 comments on commit 8c7e5c1

Please sign in to comment.