Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include <vcl_iostream.h>
00007 #include <vcl_fstream.h>
00008 #include <vul/vul_string.h>
00009 #include <mbl/mbl_log.h>
00010
00011
00012 static bool find_ENV_file(vcl_string path)
00013 {
00014 if (!vul_string_expand_var(path))
00015 return false;
00016 vcl_ifstream config_file(path.c_str());
00017 if (config_file.is_open())
00018 {
00019 vcl_cout << "Found " << path << "\n";
00020 return true;
00021 }
00022 return false;
00023 }
00024
00025 static bool find_file(const vcl_string & path)
00026 {
00027 vcl_ifstream config_file(path.c_str());
00028 if (config_file.is_open())
00029 {
00030 vcl_cout << "Found " << path << "\n";
00031 return true;
00032 }
00033 return false;
00034 }
00035
00036 static void find_properties_file()
00037 {
00038 vcl_ifstream config_file("mbl_log.properties");
00039 if (find_file("./mbl_log.properties")) return;
00040 if (find_file("~/mbl_log.properties")) return;
00041 if (find_file("~/.mbl_log.properties")) return;
00042 if (find_ENV_file("${HOME}/mbl_log.properties")) return;
00043 if (find_ENV_file("${HOME}/.mbl_log.properties")) return;
00044 if (find_ENV_file("${HOMESHARE}/mbl_log.properties")) return;
00045 if (find_ENV_file("${HOMEDRIVE}${HOMEDIR}/mbl_log.properties")) return;
00046 if (find_ENV_file("${HOMEDRIVE}${HOMEPATH}/mbl_log.properties")) return;
00047 if (find_ENV_file("${USERPROFILE}/mbl_log.properties")) return;
00048 if (find_file("C:\\mbl_log.properties")) return;
00049 }
00050
00051 int main()
00052 {
00053
00054
00055 find_properties_file();
00056
00057
00058 mbl_logger::root().load_log_config_file();
00059 vcl_cout << "mbl_logger settings: ";
00060 mbl_logger::root().categories().print(vcl_cout);
00061 vcl_cout << vcl_endl;
00062
00063 return 0;
00064 }