summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostyantyn Ovechko <fastinetserver@gmail.com>2010-08-16 19:55:24 +0300
committerKostyantyn Ovechko <fastinetserver@gmail.com>2010-08-16 19:55:24 +0300
commitc80451786239fc1a8164289c811961e6999dd567 (patch)
tree0c63c27aa9c23b5fcaa7caddae7d7c1a89fef4f9 /tuiclient
parentMove example from net0.py to net0_example.py (diff)
downloadidfetch-master.tar.gz
idfetch-master.tar.bz2
idfetch-master.zip
Add try...catch blocks and correct default settings in .conf filesHEADmaster
Diffstat (limited to 'tuiclient')
-rw-r--r--tuiclient/log.cpp80
-rw-r--r--tuiclient/settings.h2
-rw-r--r--tuiclient/tuiclient.conf4
3 files changed, 48 insertions, 38 deletions
diff --git a/tuiclient/log.cpp b/tuiclient/log.cpp
index d9ee588..72008cc 100644
--- a/tuiclient/log.cpp
+++ b/tuiclient/log.cpp
@@ -36,21 +36,23 @@ void log(string log_msg_text){
}
void log_no_msg(string log_msg_text){
try{
- ofstream file;
- file.exceptions (ofstream::failbit | ofstream::badbit);
- try{
- file.open((settings.logs_dir+"/"+settings.general_log_file).c_str(), ios::app);
- }catch(...){
- error_log("Error opening "+settings.logs_dir+"/"+settings.general_log_file+".");
- return;
- }
- try{
- file << log_msg_text << endl;
- file.close();
- }
- catch(...){
- error_log("Error while writing "+settings.logs_dir+"/"+settings.general_log_file+".");
- return;
+ if (settings.general_log_file!="none"){
+ ofstream file;
+ file.exceptions (ofstream::failbit | ofstream::badbit);
+ try{
+ file.open((settings.logs_dir+"/"+settings.general_log_file).c_str(), ios::app);
+ }catch(...){
+ error_log("Error opening "+settings.logs_dir+"/"+settings.general_log_file+".");
+ return;
+ }
+ try{
+ file << log_msg_text << endl;
+ file.close();
+ }
+ catch(...){
+ error_log("Error while writing "+settings.logs_dir+"/"+settings.general_log_file+".");
+ return;
+ }
}
}catch(...){
error_log("Error in tui.cpp: log()");
@@ -67,23 +69,29 @@ void debug(string debug_msg_text){
void debug_no_msg(string debug_msg_text){
try{
- ofstream file;
- file.exceptions (ofstream::failbit | ofstream::badbit);
- try{
-// file.open((settings.logs_dir+"/"+settings.debug_log_file).c_str(), ios::app);
- file.open("./logs/debug.log", ios::app);
- }
- catch(...){
- error_log("Error opening "+settings.logs_dir+"/"+settings.debug_log_file+".");
- return;
- }
- try{
- file << debug_msg_text << endl;
- file.close();
- }
- catch(...){
- error_log("Error while writing "+settings.logs_dir+"/"+settings.debug_log_file+".");
- return;
+ if (settings.debug_log_file!="none"){
+ ofstream file;
+ file.exceptions (ofstream::failbit | ofstream::badbit);
+ try{
+ file.open((settings.logs_dir+"/"+settings.debug_log_file).c_str(), ios::app);
+ if (! file.is_open()){
+ error_log("Error opening "+settings.logs_dir+"/"+settings.debug_log_file+" for writing.");
+ error_log("....Check if folder "+settings.logs_dir+" exists and seggetd has permissions to write into it.");
+ return;
+ }
+ }
+ catch(...){
+ error_log("Error opening "+settings.logs_dir+"/"+settings.debug_log_file+" for writing.");
+ error_log("....Check if folder "+settings.logs_dir+" exists and seggetd has permissions to write into it.");
+ return;
+ }
+ try{
+ file << debug_msg_text << endl;
+ file.close();
+ }catch(...){
+ error_log("Error while writing "+settings.logs_dir+"/"+settings.debug_log_file+".");
+ return;
+ }
}
}catch(...){
error_log("Error in tui.cpp: debug()");
@@ -92,9 +100,11 @@ void debug_no_msg(string debug_msg_text){
void error_log_no_msg(string error_msg_text){
try{
- ofstream file ((settings.logs_dir+"/"+settings.error_log_file).c_str(), ios::app);
- file << error_msg_text << endl;
- file.close();
+ if (settings.error_log_file!="none"){
+ ofstream file ((settings.logs_dir+"/"+settings.error_log_file).c_str(), ios::app);
+ file << error_msg_text << endl;
+ file.close();
+ }
}catch(...){
// fprintf(stderr, "Error opening error log file.");
// fprintf(stderr, "Error log file: %s/%s",settings.logs_dir.c_str(),settings.error_log_file.c_str());
diff --git a/tuiclient/settings.h b/tuiclient/settings.h
index 22fd167..666f98f 100644
--- a/tuiclient/settings.h
+++ b/tuiclient/settings.h
@@ -171,7 +171,7 @@ class Tsettings{
logs_dir("/var/log/seggetd"),
general_log_file("tuiclient.log"),
error_log_file("tuiclient_error.log"),
- debug_log_file("tuiclient_debug.log")
+ debug_log_file("none")
{};
void init();
};
diff --git a/tuiclient/tuiclient.conf b/tuiclient/tuiclient.conf
index 6092a0a..fbadd60 100644
--- a/tuiclient/tuiclient.conf
+++ b/tuiclient/tuiclient.conf
@@ -100,5 +100,5 @@ error_log_file=tuiclient_error.log
# DEBUG_LOG_FILE
# Define a file name to store debug log.
# Default:
-# debug_log_file=tuiclient_debug.log
-debug_log_file=tuiclient_debug.log \ No newline at end of file
+# debug_log_file=none
+debug_log_file=none \ No newline at end of file