Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions src/axom/lumberjack/LineFileTagCombiner.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Copyright (c) 2017-2025, Lawrence Livermore National Security, LLC and
// other Axom Project Developers. See the top-level LICENSE file for details.
//
// SPDX-License-Identifier: (BSD-3-Clause)

/*!
*******************************************************************************
* \file LineFileTagCombiner.hpp
*
* \brief This file contains the class implementation of the
* LineFileTagCombiner.
*******************************************************************************
*/

#ifndef LINEFILETAGCOMBINER_HPP
#define LINEFILETAGCOMBINER_HPP

#include "axom/lumberjack/Combiner.hpp"
#include "axom/lumberjack/Message.hpp"

#include <string>

namespace axom
{
namespace lumberjack
{
/*!
*******************************************************************************
* \class LineFileTagCombiner
*
* \brief Combines Message classes if their Message::fileName,
* Message::lineNumer, and Message::tag are equal.
*
*******************************************************************************
*/
class LineFileTagCombiner : public axom::lumberjack::Combiner
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is nearly identical to the TextTagCombiner, with the exception of the criteria used to determine whether the message should be combined.

{
public:
LineFileTagCombiner() { }

/*!
*****************************************************************************
* \brief Returns the unique string identifier for this combiner. Used by
* Lumberjack to differentiate between other combiners.
*****************************************************************************
*/
const std::string id() { return m_id; }

/*!
*****************************************************************************
* \brief Function used by Lumberjack to indicate whether two messages should
* be combined.
*
* They are not actually combined by this function. Message classes are
* triggered for combination if Message::fileName, Message::lineNumer,
* and Message::tag are equal.
*
* \param [in] leftMessage One of the Messages to be compared.
* \param [in] rightMessage One of the Messages to be compared.
*****************************************************************************
*/
bool shouldMessagesBeCombined(const axom::lumberjack::Message& leftMessage,
const axom::lumberjack::Message& rightMessage)
{
return ((leftMessage.lineNumber() == rightMessage.lineNumber()) &&
leftMessage.fileName().compare(rightMessage.fileName()) == 0 &&
leftMessage.tag().compare(rightMessage.tag()) == 0);
}

/*!
*****************************************************************************
* \brief Combines the combinee into the combined Message.
*
* The only thing truly combined in this Combiner is the ranks from combinee
* to combined. The text will not be combined, even if it is not equal.
* Only text from the first message will be saved.
*
* \param [in,out] combined the Message that will be modified.
* \param [in] combinee the Message that is combined into the other.
* \param [in] ranksLimit The limit on how many individual ranks are tracked
* in the combined Message. Message::rankCount is always incremented.
*
* \pre shouldMessagesBeCombined(combined, combinee) must be true
*****************************************************************************
*/
void combine(axom::lumberjack::Message& combined,
const axom::lumberjack::Message& combinee,
const int ranksLimit)
{
combined.addRanks(combinee.ranks(), combinee.count(), ranksLimit);
}

private:
const std::string m_id = "LineFileTagCombiner";
};

} // end namespace lumberjack
} // end namespace axom

#endif
3 changes: 2 additions & 1 deletion src/axom/lumberjack/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ set(lumberjack_serial_tests
lumberjack_Lumberjack.hpp
lumberjack_Message.hpp
lumberjack_TextEqualityCombiner.hpp
lumberjack_TextTagCombiner.hpp )
lumberjack_TextTagCombiner.hpp
lumberjack_LineFileTagCombiner.hpp )

axom_add_executable(NAME lumberjack_serial_tests
SOURCES lumberjack_serial_main.cpp
Expand Down
Loading