forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Celeritas error and output handling in celer-g4 app (celeritas-pr…
…oject#1013) * Add convenience functino for getting number of threads from geant4 run manager * Add log messages * Add `to_color_code` for logger levels * Move g4 exception disabling to GeantUtils * Add additional diagnostics to g4-only output registry * Use Celeritas error handling and logging for celer-g4 * Add scoped profiling to actual run * Fix no-geant4 inline functions * Add field validation * Pass more data instead of using global static * Mark manager thread from local logger to distinguish from global CELER_LOG * Fix recursive mutex deadlock
- Loading branch information
Showing
33 changed files
with
445 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2023 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file celer-g4/LocalLogger.cc | ||
//---------------------------------------------------------------------------// | ||
#include "LocalLogger.hh" | ||
|
||
#include <G4Threading.hh> | ||
|
||
#include "corecel/io/ColorUtils.hh" | ||
|
||
namespace celeritas | ||
{ | ||
namespace app | ||
{ | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Write a log message. | ||
*/ | ||
void LocalLogger::operator()(Provenance prov, LogLevel lev, std::string msg) | ||
{ | ||
int local_thread = G4Threading::G4GetThreadId(); | ||
std::clog << color_code('W') << '['; | ||
if (local_thread >= 0) | ||
{ | ||
std::clog << local_thread + 1; | ||
} | ||
else | ||
{ | ||
std::clog << 'M'; | ||
} | ||
std::clog << '/' << num_threads_ << "] " << color_code(' '); | ||
|
||
if (lev == LogLevel::debug || lev >= LogLevel::warning) | ||
{ | ||
// Output problem line/file for debugging or high level | ||
std::clog << color_code('x') << prov.file; | ||
if (prov.line) | ||
std::clog << ':' << prov.line; | ||
std::clog << color_code(' ') << ": "; | ||
} | ||
|
||
std::clog << to_color_code(lev) << to_cstring(lev) << ": " | ||
<< color_code(' ') << msg << std::endl; | ||
} | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace app | ||
} // namespace celeritas |
Oops, something went wrong.