-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1264 from LLNL/feature/han12/slic_tags
Slic tags for streams and messages
- Loading branch information
Showing
29 changed files
with
886 additions
and
124 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright (c) 2017-2023, 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 TextTagCombiner.hpp | ||
* | ||
* \brief This file contains the class implementation of the | ||
* TextTagCombiner. | ||
******************************************************************************* | ||
*/ | ||
|
||
#ifndef TEXTTAGCOMBINER_HPP | ||
#define TEXTTAGCOMBINER_HPP | ||
|
||
#include "axom/lumberjack/Combiner.hpp" | ||
#include "axom/lumberjack/Message.hpp" | ||
|
||
#include <string> | ||
|
||
namespace axom | ||
{ | ||
namespace lumberjack | ||
{ | ||
/*! | ||
******************************************************************************* | ||
* \class TextTagCombiner | ||
* | ||
* \brief Combines Message classes if their Message::text and Message::tag | ||
* are equal. | ||
* | ||
* This class can be added to Lumberjack's Lumberjack by calling | ||
* Lumberjack::addCombiner with a | ||
* TextTagCombiner instance as its parameter. | ||
* | ||
* \see Combiner Lumberjack | ||
******************************************************************************* | ||
*/ | ||
class TextTagCombiner : public Combiner | ||
{ | ||
public: | ||
TextTagCombiner() { } | ||
|
||
/*! | ||
***************************************************************************** | ||
* \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 both Message::text 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 Message& leftMessage, | ||
const Message& rightMessage) | ||
{ | ||
return (leftMessage.text().compare(rightMessage.text()) == 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, since text is already equal. | ||
* | ||
* \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(Message& combined, const Message& combinee, const int ranksLimit) | ||
{ | ||
combined.addRanks(combinee.ranks(), combinee.count(), ranksLimit); | ||
} | ||
|
||
private: | ||
const std::string m_id = "TextTagCombiner"; | ||
}; | ||
|
||
} // end namespace lumberjack | ||
} // end namespace axom | ||
|
||
#endif |
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
110 changes: 110 additions & 0 deletions
110
src/axom/lumberjack/tests/lumberjack_TextTagCombiner.hpp
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,110 @@ | ||
// Copyright (c) 2017-2023, Lawrence Livermore National Security, LLC and | ||
// other Axom Project Developers. See the top-level LICENSE file for details. | ||
// | ||
// SPDX-License-Identifier: (BSD-3-Clause) | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "axom/lumberjack/TextTagCombiner.hpp" | ||
|
||
TEST(lumberjack_TextTagCombiner, case01) | ||
{ | ||
//Test positive case: two equal texts and tags | ||
std::string text = "I never wanted to do this job in the first place!"; | ||
axom::lumberjack::Message m1; | ||
m1.text(text); | ||
m1.addRank(13, 5); | ||
m1.fileName("foo.cpp"); | ||
m1.lineNumber(154); | ||
m1.tag("myTag"); | ||
|
||
axom::lumberjack::Message m2; | ||
m2.text(text); | ||
m2.addRank(14, 5); | ||
m2.fileName("foo.cpp"); | ||
m2.lineNumber(154); | ||
m2.tag("myTag"); | ||
|
||
axom::lumberjack::TextTagCombiner c; | ||
|
||
bool shouldMessagesBeCombined = c.shouldMessagesBeCombined(m1, m2); | ||
|
||
c.combine(m1, m2, 5); | ||
|
||
EXPECT_EQ(shouldMessagesBeCombined, true); | ||
EXPECT_EQ(m1.text().compare(text), 0); | ||
EXPECT_EQ(m1.count(), 2); | ||
EXPECT_EQ(m1.ranks()[0], 13); | ||
EXPECT_EQ(m1.ranks()[1], 14); | ||
EXPECT_EQ(m2.tag().compare("myTag"), 0); | ||
} | ||
|
||
TEST(lumberjack_TextTagCombiner, case02) | ||
{ | ||
//Test negative case: two not-equal texts, but equal tags | ||
std::string text1 = "I never wanted to do this job in the first place!"; | ||
axom::lumberjack::Message m1; | ||
m1.text(text1); | ||
m1.addRank(13, 5); | ||
m1.fileName("foo.cpp"); | ||
m1.lineNumber(154); | ||
m1.tag("myTag"); | ||
|
||
std::string text2 = "This text is not equal to the first."; | ||
axom::lumberjack::Message m2; | ||
m2.text(text2); | ||
m2.addRank(14, 5); | ||
m2.fileName("foo.cpp"); | ||
m2.lineNumber(154); | ||
m2.tag("myTag"); | ||
|
||
axom::lumberjack::TextTagCombiner c; | ||
|
||
bool shouldMessagesBeCombined = c.shouldMessagesBeCombined(m1, m2); | ||
|
||
EXPECT_EQ(shouldMessagesBeCombined, false); | ||
EXPECT_EQ(m1.text().compare(text1), 0); | ||
EXPECT_EQ(m1.count(), 1); | ||
EXPECT_EQ(m1.ranks()[0], 13); | ||
EXPECT_EQ(m1.tag().compare("myTag"), 0); | ||
|
||
EXPECT_EQ(m2.text().compare(text2), 0); | ||
EXPECT_EQ(m2.count(), 1); | ||
EXPECT_EQ(m2.ranks()[0], 14); | ||
EXPECT_EQ(m2.tag().compare("myTag"), 0); | ||
} | ||
|
||
TEST(lumberjack_TextTagCombiner, case03) | ||
{ | ||
//Test negative case: two equal texts, but not-equal tags | ||
std::string text = "I never wanted to do this job in the first place!"; | ||
|
||
axom::lumberjack::Message m1; | ||
m1.text(text); | ||
m1.addRank(13, 5); | ||
m1.fileName("foo.cpp"); | ||
m1.lineNumber(154); | ||
m1.tag("tag1"); | ||
|
||
axom::lumberjack::Message m2; | ||
m2.text(text); | ||
m2.addRank(14, 5); | ||
m2.fileName("foo.cpp"); | ||
m2.lineNumber(154); | ||
m2.tag("tag2"); | ||
|
||
axom::lumberjack::TextTagCombiner c; | ||
|
||
bool shouldMessagesBeCombined = c.shouldMessagesBeCombined(m1, m2); | ||
|
||
EXPECT_EQ(shouldMessagesBeCombined, false); | ||
EXPECT_EQ(m1.text().compare(text), 0); | ||
EXPECT_EQ(m1.count(), 1); | ||
EXPECT_EQ(m1.ranks()[0], 13); | ||
EXPECT_EQ(m1.tag().compare("tag1"), 0); | ||
|
||
EXPECT_EQ(m2.text().compare(text), 0); | ||
EXPECT_EQ(m2.count(), 1); | ||
EXPECT_EQ(m2.ranks()[0], 14); | ||
EXPECT_EQ(m2.tag().compare("tag2"), 0); | ||
} |
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
Oops, something went wrong.