Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
janekbaraniewski committed Apr 29, 2024
1 parent 26bb0cb commit bb9a7b3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion include/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/support/date_time.hpp>

// Namespace aliases
namespace logging = boost::log;
namespace src = boost::log::sources;
namespace expr = boost::log::expressions;
Expand Down
2 changes: 1 addition & 1 deletion src/SerialServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int main(int argc, char* argv[]) {
server.run();
} catch (const std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "Exception: " << e.what();
return 1; // Ensure returning a non-zero value on error
return 1;
}
return 0;
}
Expand Down
5 changes: 2 additions & 3 deletions src/VirtualSerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ VirtualSerialPort::VirtualSerialPort(const std::string& device) : device_name_("
throw std::runtime_error("Failed to get PTY slave name");
}

unlink(device_name_.c_str()); // Ensure no stale symlink exists
unlink(device_name_.c_str());
if (symlink(slave_name, device_name_.c_str()) != 0) {
throw std::runtime_error("Failed to create symlink for PTY slave");
}
Expand All @@ -21,7 +21,6 @@ VirtualSerialPort::VirtualSerialPort(const std::string& device) : device_name_("
throw std::runtime_error("Failed to open PTY slave");
}

// Set permissions to allow external applications to access the virtual serial port
chmod(device_name_.c_str(), 0666);
}

Expand All @@ -32,7 +31,7 @@ VirtualSerialPort::~VirtualSerialPort() {
void VirtualSerialPort::close() {
::close(master_fd_);
::close(slave_fd_);
unlink(device_name_.c_str()); // Clean up the symlink on destruction
unlink(device_name_.c_str());
}

bool VirtualSerialPort::write(const std::string& data) {
Expand Down
6 changes: 3 additions & 3 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
src::severity_logger<boost::log::trivial::severity_level> lg;

void init_logging() {
logging::add_common_attributes(); // Adds common attributes like LineID, TimeStamp
logging::add_common_attributes();

logging::add_console_log(
std::cout,
Expand All @@ -17,8 +17,8 @@ void init_logging() {
);

logging::add_file_log(
keywords::file_name = "serial_application_%N.log", // File name pattern
keywords::rotation_size = 10 * 1024 * 1024, // Rotate files every 10 MiB
keywords::file_name = "serial_application_%N.log",
keywords::rotation_size = 10 * 1024 * 1024, // Rotate files every 10 MiB
keywords::time_based_rotation = logging::sinks::file::rotation_at_time_point(0, 0, 0),
keywords::format = (
expr::stream
Expand Down

0 comments on commit bb9a7b3

Please sign in to comment.