Commit 5752a0de7fc8555fae8813229047efc2e6d712b4
1 parent
29226bbd
Adjust the log output
Showing
11 changed files
with
48 additions
and
30 deletions
src/ctbin/ctbin.cpp
src/ctbkgcube/ctbkgcube.cpp
| ... | ... | @@ -401,8 +401,8 @@ void ctbkgcube::save(void) |
| 401 | 401 | |
| 402 | 402 | // Log filename |
| 403 | 403 | if (logTerse()) { |
| 404 | - log << "Save background cube into file \""+m_outcube+"\"."; | |
| 405 | - log << std::endl; | |
| 404 | + log << gammalib::parformat("Background cube file"); | |
| 405 | + log << m_outcube.url() << std::endl; | |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | // Save background cube |
| ... | ... | @@ -416,8 +416,8 @@ void ctbkgcube::save(void) |
| 416 | 416 | |
| 417 | 417 | // Log filename |
| 418 | 418 | if (logTerse()) { |
| 419 | - log << "Save model into file \""+m_outmodel.url()+"\"."; | |
| 420 | - log << std::endl; | |
| 419 | + log << gammalib::parformat("Model definition file"); | |
| 420 | + log << m_outmodel.url() << std::endl; | |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | // Save output model for stacked analyses |
| ... | ... | @@ -451,7 +451,8 @@ void ctbkgcube::publish(const std::string& name) |
| 451 | 451 | |
| 452 | 452 | // Log filename |
| 453 | 453 | if (logTerse()) { |
| 454 | - log << "Publish \""+user_name+"\" background cube." << std::endl; | |
| 454 | + log << gammalib::parformat("Publish background cube"); | |
| 455 | + log << user_name << std::endl; | |
| 455 | 456 | } |
| 456 | 457 | |
| 457 | 458 | // Publish exposure cube | ... | ... |
src/ctcubemask/ctcubemask.cpp
| ... | ... | @@ -746,8 +746,8 @@ void ctcubemask::save_fits(void) |
| 746 | 746 | |
| 747 | 747 | // Log filename |
| 748 | 748 | if (logTerse()) { |
| 749 | - log << "Save counts cube into file \""+m_outcube+"\"."; | |
| 750 | - log << std::endl; | |
| 749 | + log << gammalib::parformat("Counts cube file"); | |
| 750 | + log << m_outcube.url() << std::endl; | |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | // Save event list |
| ... | ... | @@ -802,8 +802,8 @@ void ctcubemask::save_xml(void) |
| 802 | 802 | |
| 803 | 803 | // Log filename |
| 804 | 804 | if (logTerse()) { |
| 805 | - log << "Save counts cube into file \""+outfile+"\"."; | |
| 806 | - log << std::endl; | |
| 805 | + log << gammalib::parformat("Counts cube file"); | |
| 806 | + log << outfile << std::endl; | |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | // Save event list | ... | ... |
src/ctedispcube/ctedispcube.cpp
| ... | ... | @@ -286,8 +286,8 @@ void ctedispcube::save(void) |
| 286 | 286 | |
| 287 | 287 | // Log filename |
| 288 | 288 | if (logTerse()) { |
| 289 | - log << "Save energy dispersion cube into file \""+m_outcube+"\"."; | |
| 290 | - log << std::endl; | |
| 289 | + log << gammalib::parformat("Energy dispersion cube file"); | |
| 290 | + log << m_outcube.url() << std::endl; | |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // Save energy dispersion cube | ... | ... |
src/ctexpcube/ctexpcube.cpp
| ... | ... | @@ -297,8 +297,8 @@ void ctexpcube::save(void) |
| 297 | 297 | |
| 298 | 298 | // Log filename |
| 299 | 299 | if (logTerse()) { |
| 300 | - log << "Save exposure cube into file \""+m_outcube+"\"."; | |
| 301 | - log << std::endl; | |
| 300 | + log << gammalib::parformat("Exposure cube file"); | |
| 301 | + log << m_outcube.url() << std::endl; | |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // Save exposure cube |
| ... | ... | @@ -332,7 +332,8 @@ void ctexpcube::publish(const std::string& name) |
| 332 | 332 | |
| 333 | 333 | // Log filename |
| 334 | 334 | if (logTerse()) { |
| 335 | - log << "Publish \""+user_name+"\" exposure cube." << std::endl; | |
| 335 | + log << gammalib::parformat("Publish exposure cube"); | |
| 336 | + log << user_name << std::endl; | |
| 336 | 337 | } |
| 337 | 338 | |
| 338 | 339 | // Publish exposure cube | ... | ... |
src/ctmodel/ctmodel.cpp
| ... | ... | @@ -356,8 +356,8 @@ void ctmodel::save(void) |
| 356 | 356 | |
| 357 | 357 | // Log filename |
| 358 | 358 | if (logTerse()) { |
| 359 | - log << "Save model cube into file \""+m_outcube+"\"."; | |
| 360 | - log << std::endl; | |
| 359 | + log << gammalib::parformat("Model cube file"); | |
| 360 | + log << m_outcube.url() << std::endl; | |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | // Save model cube into FITS file |
| ... | ... | @@ -391,7 +391,8 @@ void ctmodel::publish(const std::string& name) |
| 391 | 391 | |
| 392 | 392 | // Log filename |
| 393 | 393 | if (logTerse()) { |
| 394 | - log << "Publish \""+user_name+"\" model cube." << std::endl; | |
| 394 | + log << gammalib::parformat("Publish model cube"); | |
| 395 | + log << user_name << std::endl; | |
| 395 | 396 | } |
| 396 | 397 | |
| 397 | 398 | // Publish model cube | ... | ... |
src/ctpsfcube/ctpsfcube.cpp
| ... | ... | @@ -270,8 +270,8 @@ void ctpsfcube::save(void) |
| 270 | 270 | |
| 271 | 271 | // Log filename |
| 272 | 272 | if (logTerse()) { |
| 273 | - log << "Save PSF cube into file \""+m_outcube+"\"."; | |
| 274 | - log << std::endl; | |
| 273 | + log << gammalib::parformat("PSF cube file"); | |
| 274 | + log << m_outcube.url() << std::endl; | |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // Save PSF cube | ... | ... |
src/ctselect/ctselect.cpp
| ... | ... | @@ -1266,8 +1266,8 @@ void ctselect::save_fits(void) |
| 1266 | 1266 | |
| 1267 | 1267 | // Log filename |
| 1268 | 1268 | if (logTerse()) { |
| 1269 | - log << "Save event list into file \""+outfile+"\"."; | |
| 1270 | - log << std::endl; | |
| 1269 | + log << gammalib::parformat("Event list file"); | |
| 1270 | + log << outfile << std::endl; | |
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | 1273 | // Save event list |
| ... | ... | @@ -1335,8 +1335,8 @@ void ctselect::save_xml(void) |
| 1335 | 1335 | |
| 1336 | 1336 | // Log filename |
| 1337 | 1337 | if (logTerse()) { |
| 1338 | - log << "Save event list into file \""+outfile+"\"."; | |
| 1339 | - log << std::endl; | |
| 1338 | + log << gammalib::parformat("Event list file"); | |
| 1339 | + log << outfile << std::endl; | |
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | 1342 | // Store output file name in observation | ... | ... |
src/ctskymap/ctskymap.cpp
| ... | ... | @@ -322,7 +322,8 @@ void ctskymap::save(void) |
| 322 | 322 | |
| 323 | 323 | // Log filename |
| 324 | 324 | if (logTerse()) { |
| 325 | - log << "Save sky map into file \""+m_outmap+"\"." << std::endl; | |
| 325 | + log << gammalib::parformat("Sky map file"); | |
| 326 | + log << m_outmap.url() << std::endl; | |
| 326 | 327 | } |
| 327 | 328 | |
| 328 | 329 | // Create empty FITS file |
| ... | ... | @@ -362,7 +363,8 @@ void ctskymap::publish(const std::string& name) |
| 362 | 363 | |
| 363 | 364 | // Log filename |
| 364 | 365 | if (logTerse()) { |
| 365 | - log << "Publish \""+user_name+"\" sky map." << std::endl; | |
| 366 | + log << gammalib::parformat("Publish sky map"); | |
| 367 | + log << user_name << std::endl; | |
| 366 | 368 | } |
| 367 | 369 | |
| 368 | 370 | // Publish sky map | ... | ... |
src/cttsmap/cttsmap.cpp
| ... | ... | @@ -399,7 +399,8 @@ void cttsmap::save(void) |
| 399 | 399 | |
| 400 | 400 | // Log filename |
| 401 | 401 | if (logTerse()) { |
| 402 | - log << "Save TS map into file \""+m_outmap+"\"." << std::endl; | |
| 402 | + log << gammalib::parformat("TS map file"); | |
| 403 | + log << m_outmap.url() << std::endl; | |
| 403 | 404 | } |
| 404 | 405 | |
| 405 | 406 | // Create fits file |
| ... | ... | @@ -453,7 +454,8 @@ void cttsmap::publish(const std::string& name) |
| 453 | 454 | |
| 454 | 455 | // Log filename |
| 455 | 456 | if (logTerse()) { |
| 456 | - log << "Publish \""+user_name+"\" TS map." << std::endl; | |
| 457 | + log << gammalib::parformat("Publish TS map"); | |
| 458 | + log << user_name << std::endl; | |
| 457 | 459 | } |
| 458 | 460 | |
| 459 | 461 | // Publish TS map | ... | ... |
test/test_ctbin.py
| ... | ... | @@ -73,7 +73,8 @@ class Test(test): |
| 73 | 73 | ' outcube="cntmap_cmd1.fits"'+\ |
| 74 | 74 | ' emin=0.1 emax=100.0 enumbins=20 ebinalg="LOG"'+ \ |
| 75 | 75 | ' nxpix=200 nypix=200 binsz=0.02 coordsys="CEL"'+ \ |
| 76 | - ' xref=83.63 yref=22.01 proj="CAR"' | |
| 76 | + ' xref=83.63 yref=22.01 proj="CAR"'+ \ | |
| 77 | + ' logfile="ctbin_cmd1.log" chatter=1' | |
| 77 | 78 | |
| 78 | 79 | # Check if execution of wrong command fails |
| 79 | 80 | self.test_assert(self._execute('command_that_does_not_exist') != 0, |
| ... | ... | @@ -92,7 +93,8 @@ class Test(test): |
| 92 | 93 | ' outcube="cntmap_cmd2.fits"'+\ |
| 93 | 94 | ' emin=0.1 emax=100.0 enumbins=20 ebinalg="LOG"'+ \ |
| 94 | 95 | ' nxpix=200 nypix=200 binsz=0.02 coordsys="CEL"'+ \ |
| 95 | - ' xref=83.63 yref=22.01 proj="CAR"' | |
| 96 | + ' xref=83.63 yref=22.01 proj="CAR"'+ \ | |
| 97 | + ' logfile="ctbin_cmd1.log" chatter=1' | |
| 96 | 98 | |
| 97 | 99 | # Check if execution failed |
| 98 | 100 | self.test_assert(self._execute(cmd) != 0, |
| ... | ... | @@ -121,8 +123,11 @@ class Test(test): |
| 121 | 123 | bin['proj'] = 'CAR' |
| 122 | 124 | bin['xref'] = 83.63 |
| 123 | 125 | bin['yref'] = 22.01 |
| 126 | + bin['logfile'] = 'ctbin_py1.log' | |
| 127 | + bin['chatter'] = 2 | |
| 124 | 128 | |
| 125 | 129 | # Run ctbin tool |
| 130 | + bin.logFileOpen() # Make sure we get a log file | |
| 126 | 131 | bin.run() |
| 127 | 132 | |
| 128 | 133 | # Check content of observation and cube |
| ... | ... | @@ -137,6 +142,8 @@ class Test(test): |
| 137 | 142 | self._check_cube(cpy_bin.cube(), 5542) |
| 138 | 143 | |
| 139 | 144 | # Run copy of ctbin tool again |
| 145 | + cpy_bin['logfile'] = 'ctbin_py2.log' | |
| 146 | + cpy_bin['chatter'] = 3 | |
| 140 | 147 | cpy_bin.run() |
| 141 | 148 | |
| 142 | 149 | # Check content of observation and cube. We expect now an empty |
| ... | ... | @@ -177,8 +184,11 @@ class Test(test): |
| 177 | 184 | bin['proj'] = 'CAR' |
| 178 | 185 | bin['xref'] = 83.63 |
| 179 | 186 | bin['yref'] = 22.01 |
| 187 | + bin['logfile'] = 'ctbin_py3.log' | |
| 188 | + bin['chatter'] = 4 | |
| 180 | 189 | |
| 181 | 190 | # Run ctbin tool |
| 191 | + bin.logFileOpen() # Make sure we get a log file | |
| 182 | 192 | bin.run() |
| 183 | 193 | |
| 184 | 194 | # Check content of observation and cube (need multiplier=3 since |
| ... | ... | @@ -200,6 +210,8 @@ class Test(test): |
| 200 | 210 | bin['proj'] = 'CAR' |
| 201 | 211 | bin['xref'] = 83.63 |
| 202 | 212 | bin['yref'] = 22.01 |
| 213 | + bin['logfile'] = 'ctbin_py4.log' | |
| 214 | + bin['chatter'] = 4 | |
| 203 | 215 | |
| 204 | 216 | # Execute ctbin tool |
| 205 | 217 | bin.execute() | ... | ... |