Skip to content

Commit

Permalink
Revert "Introduced FileResource class for logging."
Browse files Browse the repository at this point in the history
This reverts commit aa55479.
  • Loading branch information
Peguen committed Sep 4, 2024
1 parent 0623939 commit 3ea8dcd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 140 deletions.
1 change: 0 additions & 1 deletion ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ endif()
# logging
######################################
set(ecal_logging_src
src/logging/ecal_file_resource.cpp
src/logging/ecal_log.cpp
src/logging/ecal_log_impl.cpp
src/logging/ecal_log_impl.h
Expand Down
76 changes: 0 additions & 76 deletions ecal/core/src/logging/ecal_file_resource.cpp

This file was deleted.

53 changes: 0 additions & 53 deletions ecal/core/src/logging/ecal_file_resource.h

This file was deleted.

15 changes: 8 additions & 7 deletions ecal/core/src/logging/ecal_log_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ namespace eCAL
{
CLog::CLog(const Logging::SAttributes& attr_) :
m_created(false),
m_attributes(attr_)
m_attributes(attr_),
m_logfile(nullptr)
{
}

Expand All @@ -162,20 +163,19 @@ namespace eCAL
// create log file if file logging is enabled
if(m_attributes.file.enabled)
{
bool file_opened = false;
if (isDirectory(m_attributes.file.path))
{
const std::string tstring = get_time_str();

m_logfile_name = m_attributes.file.path + tstring + "_" + m_attributes.unit_name + "_" + std::to_string(m_attributes.process_id) + ".log";
file_opened = m_logfile.fopen(m_logfile_name.c_str(), "w");
m_logfile = fopen(m_logfile_name.c_str(), "w");
}
else
{
logWarningToConsole("Logging for file enabled, but specified path to log is not valid: " + m_attributes.file.path);
}

if (!file_opened)
if (m_logfile == nullptr)
{
logWarningToConsole("Logging for file enabled, but file could not be created.");
}
Expand Down Expand Up @@ -218,7 +218,8 @@ namespace eCAL

m_udp_logging_sender.reset();

if(m_logfile.isOpen()) m_logfile.fclose();
if(m_logfile != nullptr) fclose(m_logfile);
m_logfile = nullptr;

m_created = false;
}
Expand Down Expand Up @@ -280,8 +281,8 @@ namespace eCAL

if (log_to_file)
{
m_logfile.fprintf("%s\n", m_log_message_stream.str().c_str());
m_logfile.fflush();
fprintf(m_logfile, "%s\n", m_log_message_stream.str().c_str());
fflush(m_logfile);
}
}

Expand Down
4 changes: 1 addition & 3 deletions ecal/core/src/logging/ecal_log_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

#include "attributes/logging_attributes.h"
#include "ecal_global_accessors.h"
#include "ecal_file_resource.h"

#include <atomic>
#include <list>
Expand All @@ -44,7 +43,6 @@
#include <string>
#include <vector>


namespace eCAL
{
class CLog
Expand Down Expand Up @@ -143,7 +141,7 @@ namespace eCAL
std::shared_ptr<UDP::CSampleReceiver> m_log_receiver;

std::string m_logfile_name;
Logging::FileResource m_logfile;
FILE* m_logfile;

Logging::SAttributes m_attributes;
std::stringstream m_log_message_stream;
Expand Down

0 comments on commit 3ea8dcd

Please sign in to comment.