Skip to content
This repository has been archived by the owner on Jan 6, 2020. It is now read-only.

Commit

Permalink
move server name/port/dir from InitialiseVLOG to visuliaser's initial…
Browse files Browse the repository at this point in the history
… list
  • Loading branch information
maqi committed Aug 13, 2014
1 parent 2f9df27 commit 80aa549
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
8 changes: 3 additions & 5 deletions include/maidsafe/common/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ class Logging {
// Returns unused options
template <typename Char>
std::vector<std::vector<Char>> Initialise(int argc, Char** argv);
void InitialiseVlog(const std::string& prefix, const std::string& session_id,
const std::string& server_name, uint16_t server_port,
const std::string& server_dir);
void InitialiseVlog(const std::string& prefix, const std::string& session_id);
void Send(std::function<void()> message_functor);
void WriteToCombinedLogfile(const std::string& message);
void WriteToVisualiserLogfile(const std::string& message);
Expand All @@ -162,8 +160,8 @@ class Logging {
};
struct Visualiser {
Visualiser() : prefix("Vault ID uninitialised"), session_id(), logfile(), server_stream(),
server_name(), server_dir(), server_port(0), initialised(false),
initialised_once_flag() {}
server_name("visualiser.maidsafe.net"), server_dir("/log"), server_port(8080),

This comment has been minimized.

Copy link
@Viv-Rajkumar

Viv-Rajkumar Aug 13, 2014

Contributor

If we move the server_name/port/path to common, wouldn't it be better to just have these as const seeing we never change those at runtime anyways?

initialised(false), initialised_once_flag() {}
std::string prefix, session_id;
LogFile logfile;
boost::asio::ip::tcp::iostream server_stream;
Expand Down
10 changes: 3 additions & 7 deletions src/maidsafe/common/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,7 @@ std::vector<std::vector<wchar_t>> Logging::Initialise(int argc, wchar_t** argv)
return unused_options;
}

void Logging::InitialiseVlog(const std::string& prefix, const std::string& session_id,
const std::string& server_name, uint16_t server_port,
const std::string& server_dir) {
void Logging::InitialiseVlog(const std::string& prefix, const std::string& session_id) {
if (visualiser_.initialised)
BOOST_THROW_EXCEPTION(MakeError(CommonErrors::already_initialised));
std::call_once(visualiser_.initialised_once_flag, [&] {
Expand All @@ -543,10 +541,8 @@ void Logging::InitialiseVlog(const std::string& prefix, const std::string& sessi
if (visualiser_.session_id.empty())
LOG(kWarning) << "VLOG messages disabled since Vlog Session ID is empty.";
visualiser_.logfile.stream.open(GetLogfileName("visualiser").c_str(), std::ios_base::trunc);
visualiser_.server_name = server_name;
visualiser_.server_port = server_port;
visualiser_.server_dir = server_dir;
visualiser_.server_stream.connect(server_name, std::to_string(server_port));
visualiser_.server_stream.connect(visualiser_.server_name,
std::to_string(visualiser_.server_port));
if (!visualiser_.server_stream) {
LOG(kError) << "Failed to connect to VLOG server: "
<< visualiser_.server_stream.error().message();
Expand Down

0 comments on commit 80aa549

Please sign in to comment.