Skip to content

Commit

Permalink
[irods#95] use boost to get hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
SwooshyCueb committed Nov 7, 2022
1 parent 1c6fd85 commit e892a2e
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions libirods_rule_engine_plugin-audit_amqp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

// boost includes
#include <boost/any.hpp>
#include <boost/asio/ip/host_name.hpp>
#include <boost/config.hpp>
#include <boost/regex.hpp>
#include <boost/exception/all.hpp>
Expand Down Expand Up @@ -317,16 +318,13 @@ namespace

nlohmann::json json_obj;

char host_name[MAX_NAME_LEN];
gethostname(host_name, MAX_NAME_LEN);

std::string msg_str;
std::string log_file;

try {
std::uint64_t time_ms = ts_clock::now().time_since_epoch() / std::chrono::milliseconds(1);
json_obj["@timestamp"] = time_ms;
json_obj["hostname"] = host_name;
json_obj["hostname"] = boost::asio::ip::host_name();

pid_t pid = getpid();
json_obj["pid"] = pid;
Expand Down Expand Up @@ -379,9 +377,7 @@ namespace
std::uint64_t time_ms = ts_clock::now().time_since_epoch() / std::chrono::milliseconds(1);
json_obj["@timestamp"] = time_ms;

char host_name[MAX_NAME_LEN];
gethostname(host_name, MAX_NAME_LEN);
json_obj["hostname"] = host_name;
json_obj["hostname"] = boost::asio::ip::host_name();

pid_t pid = getpid();
json_obj["pid"] = pid;
Expand Down Expand Up @@ -467,11 +463,7 @@ namespace
try {
std::uint64_t time_ms = ts_clock::now().time_since_epoch() / std::chrono::milliseconds(1);
json_obj["@timestamp"] = time_ms;

char host_name[MAX_NAME_LEN];
gethostname(host_name, MAX_NAME_LEN);
json_obj["hostname"] = host_name;

json_obj["hostname"] = boost::asio::ip::host_name();
json_obj["pid"] = getpid();
json_obj["rule_name"] = _rn;

Expand Down

0 comments on commit e892a2e

Please sign in to comment.