Skip to content

Commit

Permalink
cleanup: beautified some log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Jan 16, 2019
1 parent ffcbab8 commit 3a780d2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/src/include/jcr.h
Expand Up @@ -317,7 +317,7 @@ class JobControlRecord {
bool my_thread_killable; /**< Can we kill the thread? */
public:
JobControlRecord() {
Dmsg0(100, "Contruct JobControlRecord\n");
Dmsg0(100, "Construct JobControlRecord\n");
}

~JobControlRecord() {
Expand Down
12 changes: 12 additions & 0 deletions core/src/include/version_numbers.h
Expand Up @@ -32,4 +32,16 @@ enum class BareosVersionNumber : uint32_t
kUndefined = static_cast<uint32_t>(1)
};

class BareosVersionToMajorMinor
{
public:
uint32_t major = 0;
uint32_t minor = 0;
BareosVersionToMajorMinor(BareosVersionNumber version) {
uint32_t version_number = static_cast<uint32_t>(version);
major = version_number / 100;
minor = version_number % 100;
}
};

#endif /* BAREOS_INCLUDE_RELEASE_NUMBERS_H_ */
10 changes: 8 additions & 2 deletions core/src/lib/bsock.cc
Expand Up @@ -76,7 +76,7 @@ BareosSocket::BareosSocket()
, last_tick_{0}
, tls_established_(false)
{
Dmsg0(100, "Contruct BareosSocket\n");
Dmsg0(100, "Construct BareosSocket\n");
}

BareosSocket::BareosSocket(const BareosSocket &other)
Expand Down Expand Up @@ -606,7 +606,13 @@ bool BareosSocket::EvaluateCleartextBareosHello(bool &cleartext_hello,
std::string code;
BareosVersionNumber version = BareosVersionNumber::kUndefined;
if (GetNameAndResourceTypeAndVersionFromHello(received, name, code, version)) {
Dmsg3(200, "Identified from cleartext handshake: %s-%s recognized version: %d\n", name.c_str(), code.c_str(), version);
if (version > BareosVersionNumber::kUndefined) {
BareosVersionToMajorMinor v(version);
Dmsg4(200, "Identified from Bareos handshake: %s-%s recognized version: %d.%d\n",
name.c_str(), code.c_str(), v.major, v.minor);
} else {
Dmsg2(200, "Identified from Bareos handshake: %s-%s version not recognized\n", name.c_str(), code.c_str());
}
client_name_out = name;
r_code_str_out = code;
version_out = version;
Expand Down
9 changes: 9 additions & 0 deletions core/src/tests/lib_tests.cc
Expand Up @@ -214,3 +214,12 @@ TEST(Util, version_number_test)
EXPECT_NE(BareosVersionNumber::kRelease_18_2, static_cast<BareosVersionNumber>(1702));
EXPECT_GT(BareosVersionNumber::kRelease_18_2, BareosVersionNumber::kUndefined);
}

TEST(Util, version_number_major_minor)
{
BareosVersionNumber version = BareosVersionNumber::kRelease_18_2;
BareosVersionToMajorMinor v(version);
EXPECT_EQ(v.major, 18);
EXPECT_EQ(v.minor, 2);
}

0 comments on commit 3a780d2

Please sign in to comment.