| 83 | // ---------------------------------------------------------------------------------------- |
| 84 | |
| 85 | void configure_sub_blocks ( |
| 86 | const config_reader& cr, |
| 87 | const std::string& name |
| 88 | ) |
| 89 | { |
| 90 | using namespace std; |
| 91 | |
| 92 | logger dlog(name.c_str()); |
| 93 | |
| 94 | if (cr.is_key_defined("logging_level")) |
| 95 | { |
| 96 | dlog.set_level(string_to_log_level(cr["logging_level"])); |
| 97 | } |
| 98 | |
| 99 | if (cr.is_key_defined("output")) |
| 100 | { |
| 101 | string output = cr["output"]; |
| 102 | if (output == "cout") |
| 103 | dlog.set_output_stream(cout); |
| 104 | else if (output == "cerr") |
| 105 | dlog.set_output_stream(cerr); |
| 106 | else if (output == "clog") |
| 107 | dlog.set_output_stream(clog); |
| 108 | else |
| 109 | { |
| 110 | istringstream sin(output); |
| 111 | string one, two, three; |
| 112 | sin >> one; |
| 113 | sin >> two; |
| 114 | sin >> three; |
| 115 | if (one == "file" && three.size() == 0) |
| 116 | dlog.set_output_stream(get_file_stream(two)); |
| 117 | else |
| 118 | throw error("logger_config: invalid argument to output option: " + output); |
| 119 | } |
| 120 | |
| 121 | } // if (cr.is_key_defined("output")) |
| 122 | |
| 123 | // now configure all the sub-blocks |
| 124 | std_vector_c<std::string> blocks; |
| 125 | cr.get_blocks(blocks); |
| 126 | for (unsigned long i = 0; i < blocks.size(); ++i) |
| 127 | { |
| 128 | configure_sub_blocks(cr.block(blocks[i]), name + "." + blocks[i]); |
| 129 | } |
| 130 | |
| 131 | } |
| 132 | |
| 133 | // ---------------------------------------------------------------------------------------- |
| 134 |
no test coverage detected