From 55dc0e0b80ce332982ff86a5f5c41beb6086056d Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 1 Aug 2017 16:32:13 +0800 Subject: Improve logging messages Signed-off-by: Aaron LI --- fg21sim/extragalactic/clusters/main.py | 5 +++++ fg21sim/extragalactic/clusters/solver.py | 8 ++++---- fg21sim/utils/logging.py | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py index 43c4c09..849ac57 100644 --- a/fg21sim/extragalactic/clusters/main.py +++ b/fg21sim/extragalactic/clusters/main.py @@ -241,6 +241,10 @@ class GalaxyClusters: i += 1 if i % 50 == 0: logger.info("[%d/%d] %.1f%% ..." % (i, num, 100*i/num)) + logger.info("[%d/%d] " % (i, num) + + "M1[%.2e] & M2[%.2e] @ z[%.3f] -> M[%.2e] @ z[%.3f]" % + (row.rmm_mass1, row.rmm_mass2, row.rmm_z, + row.mass, row.z)) halo = RadioHalo(M_obs=row.mass, z_obs=row.z, M_main=row.rmm_mass1, M_sub=row.rmm_mass2, z_merger=row.rmm_z, configs=self.configs) @@ -302,6 +306,7 @@ class GalaxyClusters: comment=self.catalog_comment, clobber=self.clobber) # Dump the simulated clusters data + logger.info("Dumping the simulated halos data ...") if self.halos_dumpfile is None: logger.warning("Missing dump outfile; skip dump cluster data!") else: diff --git a/fg21sim/extragalactic/clusters/solver.py b/fg21sim/extragalactic/clusters/solver.py index 67bda58..fb7c52b 100644 --- a/fg21sim/extragalactic/clusters/solver.py +++ b/fg21sim/extragalactic/clusters/solver.py @@ -381,11 +381,11 @@ class FokkerPlanckSolver: """ uc = u0 tc = tstart - logger.info("Solving Fokker-Planck equation: " + - "time: %.3f - %.3f" % (tstart, tstop)) + logger.debug("Solving Fokker-Planck equation: " + + "time: %.3f - %.3f" % (tstart, tstop)) nstep = int((tstop - tc) / self.tstep) - logger.info("Constant time step: %.3f (#%d steps)" % - (self.tstep, nstep)) + logger.debug("Constant time step: %.3f (#%d steps)" % + (self.tstep, nstep)) i = 0 while tc < tstop: i += 1 diff --git a/fg21sim/utils/logging.py b/fg21sim/utils/logging.py index d539448..c0746e8 100644 --- a/fg21sim/utils/logging.py +++ b/fg21sim/utils/logging.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Weitian LI +# Copyright (c) 2016-2017 Weitian LI # MIT license """ @@ -11,6 +11,9 @@ import logging from logging import FileHandler, StreamHandler +logger = logging.getLogger(__name__) + + def setup_logging(dict_config=None, level=None, stream=None, logfile=None): """Setup the logging. @@ -104,3 +107,4 @@ def setup_logging(dict_config=None, level=None, stream=None, logfile=None): handler = FileHandler(logfile, mode=filemode) handler.setFormatter(formatter) root_logger.addHandler(handler) + logger.info("Set up logging.") -- cgit v1.2.2