Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-08 09:39:50

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file accel/detail/LoggerImpl.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <iosfwd>
0010 #include <string_view>
0011 
0012 #include "corecel/io/LoggerTypes.hh"
0013 
0014 namespace celeritas
0015 {
0016 namespace detail
0017 {
0018 //---------------------------------------------------------------------------//
0019 //! Stream wrapper for writing an optionally abbreviated filename to output
0020 struct CleanedProvenance
0021 {
0022     std::string_view filename;
0023     int line{};
0024 };
0025 
0026 // Write abbreviated filename to output
0027 std::ostream& operator<<(std::ostream&, CleanedProvenance);
0028 
0029 //---------------------------------------------------------------------------//
0030 //! Stream wrapper for color-annotated message
0031 struct ColorfulLogMessage
0032 {
0033     LogProvenance const& prov;
0034     LogLevel lev;
0035     std::string const& msg;
0036 };
0037 
0038 // Write color-annotated message
0039 std::ostream& operator<<(std::ostream&, ColorfulLogMessage);
0040 
0041 //---------------------------------------------------------------------------//
0042 /*!
0043  * Write the Geant4 thread ID on output.
0044  */
0045 class MtSelfWriter
0046 {
0047   public:
0048     // Construct with number of threads
0049     explicit MtSelfWriter(int num_threads);
0050 
0051     // Write output with thread ID
0052     void operator()(LogProvenance prov, LogLevel lev, std::string msg) const;
0053 
0054   private:
0055     int num_threads_;
0056 };
0057 
0058 //---------------------------------------------------------------------------//
0059 }  // namespace detail
0060 }  // namespace celeritas