Skip to content

Commit f2f650e

Browse files
committed
Removed logger; Changed to LOG_* placeholder
1 parent 32b3524 commit f2f650e

23 files changed

+399
-395
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
v1.0.0.0 - [09/26/2025]
2+
- Initial Release

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
cmake_minimum_required(VERSION 3.25)
22

3-
set(CMAKE_CXX_STANDARD 23)
3+
set(CMAKE_CXX_STANDARD 20)
44
set(CMAKE_CXX_STANDARD_REQUIRED ON)
55
set(CMAKE_CXX_EXTENSIONS OFF)
66

7-
set(BUILD_VERSION 0.1.0.0)
7+
set(BUILD_VERSION 1.0.0.0)
88
project(slick_socket VERSION ${BUILD_VERSION} LANGUAGES C CXX)
99

1010
if (NOT CMAKE_BUILD_TYPE)
@@ -88,8 +88,8 @@ endif()
8888
# Automatically run install after build in Release mode
8989
if(CMAKE_BUILD_TYPE STREQUAL "Release")
9090
add_custom_target(dist_slick_socket ALL
91-
COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${CMAKE_BINARY_DIR}/dist
92-
COMMENT "Create distribution after release build"
91+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/dist/include
92+
COMMENT "Copying slick_socket headers to dist/include"
9393
VERBATIM
9494
)
9595

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# slick_socket
22

3-
A header-only C++23 networking library providing cross-platform TCP and UDP multicast communication.
3+
A header-only C++20 networking library providing cross-platform TCP and UDP multicast communication.
44

55
## Features
66

77
- **Cross-platform**: Windows and Unix/Linux support
88
- **Header-only**: No separate compilation required
9-
- **Modern C++**: C++23 template-based design with CRTP
9+
- **Modern C++**: C++20 template-based design with CRTP
1010
- **Asynchronous**: Non-blocking socket operations with timeout handling
1111
- **TCP Communication**: Client and server implementations
1212
- **UDP Multicast**: One-to-many communication support
@@ -16,7 +16,7 @@ A header-only C++23 networking library providing cross-platform TCP and UDP mult
1616

1717
### Prerequisites
1818

19-
- C++23 compatible compiler
19+
- C++20 compatible compiler
2020
- CMake 3.20 or higher
2121

2222
### Building

examples/logger.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include <iostream>
4+
#include <chrono>
5+
#include <format>
6+
7+
#define LOG_DEBUG(fmt, ...) std::cout << std::format("{:%Y-%m-%d %H:%M:%S} ", std::chrono::system_clock::now()) << "[DEBUG] " << std::format(fmt, __VA_ARGS__) << std::endl
8+
#define LOG_INFO(fmt, ...) std::cout << std::format("{:%Y-%m-%d %H:%M:%S} ", std::chrono::system_clock::now()) << "[INFO] " << std::format(fmt, __VA_ARGS__) << std::endl
9+
#define LOG_WARN(fmt, ...) std::cout << std::format("{:%Y-%m-%d %H:%M:%S} ", std::chrono::system_clock::now()) << "[WARNING] " << std::format(fmt, __VA_ARGS__) << std::endl
10+
#define LOG_ERROR(fmt, ...) std::cout << std::format("{:%Y-%m-%d %H:%M:%S} ", std::chrono::system_clock::now()) << "[ERROR] " << std::format(fmt, __VA_ARGS__) << std::endl
11+
#define LOG_TRACE(fmt, ...) std::cout << std::format("{:%Y-%m-%d %H:%M:%S} ", std::chrono::system_clock::now()) << "[TRACE] " << std::format(fmt, __VA_ARGS__) << std::endl

examples/multicast_integration_example.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "logger.h"
12
#include <slick_socket/multicast_sender.h>
23
#include <slick_socket/multicast_receiver.h>
34
#include <iostream>

examples/multicast_receiver_example.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "logger.h"
12
#include <slick_socket/multicast_receiver.h>
23
#include <iostream>
34
#include <string>

examples/multicast_sender_example.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "logger.h"
12
#include <slick_socket/multicast_sender.h>
23
#include <iostream>
34
#include <string>

examples/tcp_client_example.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "logger.h"
12
#include <slick_socket/tcp_client.h>
23
#include <iostream>
34
#include <string>
@@ -18,12 +19,12 @@ class TCPClient : public slick_socket::TCPClientBase<TCPClient>
1819

1920
void onConnected()
2021
{
21-
logger_.logInfo("Successfully connected to server");
22+
LOG_INFO("Successfully connected to server");
2223
}
2324

2425
void onDisconnected()
2526
{
26-
logger_.logInfo("Successfully disconnected from server");
27+
LOG_INFO("Successfully disconnected from server");
2728
}
2829

2930
void onData(const uint8_t* data, size_t length)

examples/tcp_server_example.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "logger.h"
12
#include <slick_socket/tcp_server.h>
23
#include <iostream>
34
#include <string>
@@ -12,12 +13,12 @@ class TCPServer : public slick_socket::TCPServerBase<TCPServer>
1213

1314
void onClientConnected(int client_id, const std::string& client_address)
1415
{
15-
logger_.logInfo("{} client connected: ID={}, Address={}", name_, client_id, client_address);
16+
LOG_INFO("{} client connected: ID={}, Address={}", name_, client_id, client_address);
1617
}
1718

1819
void onClientDisconnected(int client_id)
1920
{
20-
logger_.logInfo("{} client disconnected: ID={}", name_, client_id);
21+
LOG_INFO("{} client disconnected: ID={}", name_, client_id);
2122
}
2223

2324
void onClientData(int client_id, const uint8_t* data, size_t length)

include/slick_socket/logger.h

Lines changed: 17 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,19 @@
11
#pragma once
22

3-
#include <string>
4-
#include <iostream>
5-
#include <format>
6-
#include <chrono>
7-
8-
namespace slick_socket
9-
{
10-
11-
struct ConsoleLogger final
12-
{
13-
static ConsoleLogger& instance()
14-
{
15-
static ConsoleLogger instance;
16-
return instance;
17-
}
18-
19-
void logTrace(const std::string& format, auto&&... args)
20-
{
21-
std::cout << std::format("{:%Y-%m-%d %H:%M:%S} ", std::chrono::system_clock::now()) << "[TRACE] "
22-
<< std::vformat(format, std::make_format_args(args...)) << std::endl;
23-
}
24-
void logDebug(const std::string& format, auto&&... args)
25-
{
26-
std::cout << std::format("{:%Y-%m-%d %H:%M:%S} ", std::chrono::system_clock::now()) << "[DEBUG] "
27-
<< std::vformat(format, std::make_format_args(args...)) << std::endl;
28-
}
29-
void logInfo(const std::string& format, auto&&... args)
30-
{
31-
std::cout << std::format("{:%Y-%m-%d %H:%M:%S} ", std::chrono::system_clock::now()) << "[INFO] "
32-
<< std::vformat(format, std::make_format_args(args...)) << std::endl;
33-
}
34-
void logWarning(const std::string& format, auto&&... args)
35-
{
36-
std::cout << std::format("{:%Y-%m-%d %H:%M:%S} ", std::chrono::system_clock::now()) << "[WARN] "
37-
<< std::vformat(format, std::make_format_args(args...)) << std::endl;
38-
}
39-
void logError(const std::string& format, auto&&... args)
40-
{
41-
std::cerr << std::format("{:%Y-%m-%d %H:%M:%S} ", std::chrono::system_clock::now()) << "[ERROR] "
42-
<< std::vformat(format, std::make_format_args(args...)) << std::endl;
43-
}
44-
45-
private:
46-
ConsoleLogger() = default;
47-
~ConsoleLogger() = default;
48-
ConsoleLogger(const ConsoleLogger&) = delete;
49-
ConsoleLogger& operator=(const ConsoleLogger&) = delete;
50-
ConsoleLogger(ConsoleLogger&&) = delete;
51-
ConsoleLogger& operator=(ConsoleLogger&&) = delete;
52-
};
53-
54-
} // namespace slick_socket
3+
// Logging function placeholders
4+
// User can assign their own log functions by defining these macros before including this file
5+
#ifndef LOG_DEBUG
6+
#define LOG_DEBUG(...) do {} while(0)
7+
#endif
8+
#ifndef LOG_INFO
9+
#define LOG_INFO(...) do {} while(0)
10+
#endif
11+
#ifndef LOG_WARN
12+
#define LOG_WARN(...) do {} while(0)
13+
#endif
14+
#ifndef LOG_ERROR
15+
#define LOG_ERROR(...) do {} while(0)
16+
#endif
17+
#ifndef LOG_TRACE
18+
#define LOG_TRACE(...) do {} while(0)
19+
#endif

0 commit comments

Comments
 (0)