diff options
| author | Josh Blum <josh@joshknows.com> | 2011-05-04 14:33:35 -0700 | 
|---|---|---|
| committer | Josh Blum <josh@joshknows.com> | 2011-05-04 14:34:57 -0700 | 
| commit | 94399062713a76a42f269a7ed4d3737ecd6ed5cf (patch) | |
| tree | 2c9943d0ac8133717f1c63fd5432de110db490c7 /host/lib/utils | |
| parent | 0de4f165e937168693ac758239d569a2ace60325 (diff) | |
| download | uhd-94399062713a76a42f269a7ed4d3737ecd6ed5cf.tar.gz uhd-94399062713a76a42f269a7ed4d3737ecd6ed5cf.tar.bz2 uhd-94399062713a76a42f269a7ed4d3737ecd6ed5cf.zip  | |
uhd: tweaks for logger file entries
Diffstat (limited to 'host/lib/utils')
| -rw-r--r-- | host/lib/utils/log.cpp | 27 | 
1 files changed, 21 insertions, 6 deletions
diff --git a/host/lib/utils/log.cpp b/host/lib/utils/log.cpp index 7df077a96..061173d6b 100644 --- a/host/lib/utils/log.cpp +++ b/host/lib/utils/log.cpp @@ -142,6 +142,17 @@ UHD_SINGLETON_FCN(uhd_logger_stream_resource_class, uhd_logger_stream_resource);  /***********************************************************************   * The logger function implementation   **********************************************************************/ +//! get the relative file path from the host directory +static std::string get_rel_file_path(const fs::path &file){ +    fs::path abs_path = file.branch_path(); +    fs::path rel_path = file.leaf(); +    while (not abs_path.empty() and abs_path.leaf() != "host"){ +        rel_path = abs_path.leaf() / rel_path; +        abs_path = abs_path.branch_path(); +    } +    return rel_path.string(); +} +  uhd::_log::log::log(      const verbosity_t verbosity,      const std::string &file, @@ -151,18 +162,22 @@ uhd::_log::log::log(      uhd_logger_stream_resource().aquire(true);      uhd_logger_stream_resource().set_verbosity(verbosity);      const std::string time = pt::to_simple_string(pt::microsec_clock::local_time()); -    const std::string header = str(boost::format( -        "-- %s - lvl %d - %s @ %s:%u" -    ) % time % int(verbosity) % function % fs::path(file).leaf() % line); +    const std::string header1 = str(boost::format("-- %s - level %d") % time % int(verbosity)); +    const std::string header2 = str(boost::format("-- %s") % function).substr(0, 80); +    const std::string header3 = str(boost::format("-- %s:%u") % get_rel_file_path(file) % line); +    const std::string border = std::string(std::max(std::max(header1.size(), header2.size()), header3.size()), '-');      uhd_logger_stream_resource().get()          << std::endl -        << std::string(header.size(), '-') << std::endl -        << header << std::endl -        << std::string(header.size(), '-') << std::endl +        << border << std::endl +        << header1 << std::endl +        << header2 << std::endl +        << header3 << std::endl +        << border << std::endl      ;  }  uhd::_log::log::~log(void){ +    uhd_logger_stream_resource().get() << std::endl;      uhd_logger_stream_resource().aquire(false);  }  | 
