00001 #ifndef APPLICATION_SHELL_IMPLEMENTATION_FILE
00002 #define APPLICATION_SHELL_IMPLEMENTATION_FILE
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "application_shell.h"
00019 #include "path_configuration.h"
00020
00021 #include <basis/chaos.h>
00022 #include <basis/function.h>
00023 #include <basis/istring.h>
00024
00025 #define INI_NAME(root) (root + istring(".ini"))
00026
00027 application_shell::application_shell(const istring &root, int max_log,
00028 ini_configurator::file_location_default where)
00029 : _rando(new chaos),
00030 _root_name(new istring(root)),
00031 _ini(new ini_configurator(INI_NAME(root), ini_configurator::AUTO_STORE,
00032 where))
00033 {
00034 if (max_log) {}
00035
00036 }
00037
00038 application_shell::~application_shell()
00039 {
00040 WHACK(_root_name);
00041 WHACK(_rando);
00042 WHACK(_ini);
00043 }
00044
00045 istring application_shell::filename_root() const { return *_root_name; }
00046
00047 ini_configurator &application_shell::ini() const { return *_ini; }
00048
00049 istring application_shell::ini_name() const
00050 { return INI_NAME(filename_root()); }
00051
00052 istring application_shell::LOG_NAME(const istring &root)
00053 { return path_configuration::make_logfile_name(root + istring(".log")); }
00054
00055 istring application_shell::log_name() const
00056 { return LOG_NAME(filename_root()); }
00057
00058 outcome application_shell::log(const istring &to_print)
00059 {
00060 istring temp_log = to_print;
00064 return program_wide_logger().log(temp_log);
00065 }
00066
00067 application_shell &operator << (application_shell &out, const istring &tp)
00068 { out.log(tp); return out; }
00069
00070 #ifndef OMIT_PROGRAM_WIDE_LOGGER
00071 log_base &application_shell::logger() const { return program_wide_logger(); }
00072
00073 log_base *application_shell::swap_logger(log_base *new_logger)
00074 { return retask_program_wide_logger(new_logger); }
00075 #endif
00076
00077 outcome application_shell::log(const istring &to_print, int filter)
00078 {
00079 outcome to_return = common::OKAY;
00080 if (program_wide_logger().member(filter)) {
00081 istring temp_log = to_print;
00082 if (temp_log.length())
00083 temp_log.insert(0, utility::timestamp(true, true));
00084 to_return = program_wide_logger().log(temp_log);
00085 }
00086 return to_return;
00087 }
00088
00089
00090 #endif //APPLICATION_SHELL_IMPLEMENTATION_FILE
00091