Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e9f9685
Began porting SERVER logger to new infrastructure
marcoSanti May 19, 2026
e60358a
Moved POSIX to new logger infrastructure
marcoSanti May 19, 2026
e240a7f
Fixed segfaults
marcoSanti May 19, 2026
a855509
Fixed logger
marcoSanti May 19, 2026
81baa27
Fixed bug in server unit tests
marcoSanti May 19, 2026
4bb5111
Fixed unit tests
marcoSanti May 19, 2026
01b7446
Boh
marcoSanti May 19, 2026
de6757a
Boh
marcoSanti May 19, 2026
afdb77d
refactor
marcoSanti May 19, 2026
3b6309b
boh
marcoSanti May 19, 2026
3e91607
refactor
marcoSanti May 19, 2026
c60b8be
cleanup
marcoSanti May 19, 2026
8918e8c
format
marcoSanti May 19, 2026
56ca354
refactor
marcoSanti May 19, 2026
2986cd1
Refactor logger macro
marcoSanti May 20, 2026
c3357c9
Ported log to use JSON based logfiles
marcoSanti May 20, 2026
22ebb81
Moved logger to external project
marcoSanti May 20, 2026
f8dd8a8
Refactor namespace
marcoSanti May 20, 2026
7deeed8
reformat
marcoSanti May 20, 2026
393b8b5
readme
marcoSanti May 20, 2026
19ee15f
code-reformat
marcoSanti May 20, 2026
7b05c77
fix
marcoSanti May 20, 2026
1b29bdf
cleanup
marcoSanti May 20, 2026
8d5fe27
project rename
marcoSanti May 21, 2026
44342bc
Component name for logger
marcoSanti May 21, 2026
1902b46
Cleanup of explicit CALF usage
marcoSanti May 26, 2026
650cb2e
continue
marcoSanti Jun 9, 2026
2f76c4f
Updated calf options
marcoSanti Jun 9, 2026
db84103
Updated cmakelist
marcoSanti Jun 9, 2026
cce24c3
Updated cmake
marcoSanti Jun 9, 2026
c28b5b8
cmake fixes
marcoSanti Jun 9, 2026
7f8561b
revert
marcoSanti Jun 9, 2026
f1338d5
Improvements to cmake interface
marcoSanti Jun 9, 2026
3181f73
patched capiocl jsoncons dependency
marcoSanti Jun 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cmake-build-*
#logfies and capio files
*.log
files_location*.txt
capio_logs
capio_logs*

# Other
debug
Expand Down
29 changes: 19 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ option(CAPIO_BUILD_TESTS "Build CAPIO test suite" FALSE)
option(CAPIO_LOG "Enable capio debug logging" FALSE)
option(ENABLE_COVERAGE "Enable code coverage collection" FALSE)
option(CAPIO_BUILD_SERVER "Build CAPIO server component" TRUE)
option(CAPIO_BUILD_POSIX "Build CAPIO posix component" TRUE)
option(CAPIO_BUILD_POSIX "Build CAPIO posix component" TRUE)

#####################################
# CMake module imports
Expand Down Expand Up @@ -78,22 +78,31 @@ ENDIF (CAPIO_LOG AND CMAKE_BUILD_TYPE STREQUAL "Debug")
FetchContent_Declare(
capio_cl
GIT_REPOSITORY https://github.com/High-Performance-IO/CAPIO-CL.git
GIT_TAG v1.4.0
# GIT_TAG v1.4.0
GIT_TAG calf-integration
)

FetchContent_Declare(
calf
GIT_REPOSITORY https://github.com/High-Performance-IO/calf.git
GIT_TAG main
)

FetchContent_MakeAvailable(calf)

#####################################
# Targets
#####################################

IF(CAPIO_BUILD_POSIX)
message(STATUS "Adding CAPIO posix component")
add_subdirectory(capio/posix)
ENDIF()
IF (CAPIO_BUILD_POSIX)
message(STATUS "Adding CAPIO posix component")
add_subdirectory(capio/posix)
ENDIF ()

IF(CAPIO_BUILD_SERVER)
message(STATUS "Adding CAPIO server component")
add_subdirectory(capio/server)
ENDIF()
IF (CAPIO_BUILD_SERVER)
message(STATUS "Adding CAPIO server component")
add_subdirectory(capio/server)
ENDIF ()

IF (CAPIO_BUILD_TESTS)
message(STATUS "Building CAPIO test suite")
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ CAPIO depends on the following software that needs to be manually installed:
The following dependencies are automatically fetched during cmake configuration phase, and compiled when required.

- [CAPIO-CL](https://github.com/High-Performance-IO/CAPIO-CL) To handle the CAPIO-CL configuration and enforce streaming directives
- [CALF](https://github.com/High-Performance-IO/CALF) To manage logging and CLI printing
- [alpha-unito/syscall_intercept](https://github.com/alpha-unito/syscall_intercept) to intercept syscalls (forked from ```pmem/syscall_interept```)
- [Taywee/args](https://github.com/Taywee/args) to parse server command line inputs

Expand Down
44 changes: 9 additions & 35 deletions capio/common/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ constexpr int CAPIO_CACHE_LINE_SIZE_DEFAULT = 256 * 1024;
constexpr size_t CAPIO_SERVER_REQUEST_MAX_SIZE = sizeof(char) * (PATH_MAX + 81920);
constexpr size_t CAPIO_REQ_MAX_SIZE = 256 * sizeof(char);

constexpr char LOG_CAPIO_START_REQUEST[] = "\n+++++++++++ SYSCALL %s (%d) +++++++++++";
constexpr char LOG_CAPIO_END_REQUEST[] = "----------- END SYSCALL ----------\n";
constexpr char CAPIO_SERVER_LOG_START_REQUEST_MSG[] = "+++++++++++++++++REQUEST+++++++++++++++++";
constexpr char CAPIO_SERVER_LOG_END_REQUEST_MSG[] = "~~~~~~~~~~~~~~~END REQUEST~~~~~~~~~~~~~~~";
constexpr int CAPIO_LOG_MAX_MSG_LEN = 2048;
constexpr int CAPIO_SEM_RETRIES = 100;
constexpr int THEORETICAL_SIZE_DIRENT64 = sizeof(ino64_t) + sizeof(off64_t) +
constexpr int CAPIO_SEM_RETRIES = 100;
constexpr int THEORETICAL_SIZE_DIRENT64 = sizeof(ino64_t) + sizeof(off64_t) +
sizeof(unsigned short) + sizeof(unsigned char) +
sizeof(char) * NAME_MAX;

Expand All @@ -44,10 +39,6 @@ constexpr int CAPIO_POSIX_SYSCALL_REQUEST_SKIP = -2;
constexpr int CAPIO_POSIX_SYSCALL_SKIP = 1;
constexpr int CAPIO_POSIX_SYSCALL_SUCCESS = 0;

// CAPIO logger - common
constexpr char CAPIO_LOG_PRE_MSG[] = "at[%.15llu][%.40s]: ";
constexpr char CAPIO_DEFAULT_LOG_FOLDER[] = "capio_logs\0";

// CAPIO common - shared memory constant names
constexpr char SHM_FIRST_ELEM[] = "_first_elem_";
constexpr char SHM_LAST_ELEM[] = "_last_elem_";
Expand All @@ -66,15 +57,8 @@ constexpr char CAPIO_SHM_OPEN_ERROR[] =
"Unable to open shared memory segment. Could it be that another instance of capio server is "
"running with the same WORKFLOW_NAME?";

// CAPIO logger - POSIX
constexpr char CAPIO_LOG_POSIX_DEFAULT_LOG_FILE_PREFIX[] = "posix_thread_\0";
constexpr char CAPIO_LOG_POSIX_SYSCALL_START[] = "\n+++++++++ SYSCALL %s (%d) +++++++++";
constexpr char CAPIO_LOG_POSIX_SYSCALL_END[] = "~~~~~~~~~ END SYSCALL ~~~~~~~~~\n";

// CAPIO logger - server
constexpr char CAPIO_SERVER_DEFAULT_LOG_FILE_PREFIX[] = "server_thread_\0";
// Note: Ensure CAPIO_VERSION is defined as a string literal, e.g., #define CAPIO_VERSION "1.0.0"
constexpr char CAPIO_LOG_SERVER_BANNER[14][80] = {
constexpr char CAPIO_LOG_SERVER_BANNER[14][80] = {
"",
"\033[1;34m /$$$$$$ /$$$$$$ /$$$$$$$ \033[0;96m /$$$$$$ /$$$$$$ ",
"\033[1;34m /$$__ $$ /$$__ $$| $$__ $$ \033[0;96m|_ $$_/ /$$__ $$",
Expand All @@ -91,27 +75,24 @@ constexpr char CAPIO_LOG_SERVER_BANNER[14][80] = {
"",
};

constexpr char CAPIO_LOG_SERVER_CLI_LOGGING_NOT_AVAILABLE[] =
"CAPIO_LOG set but log support was not compiled into CAPIO!";
constexpr char CAPIO_LOG_SERVER_REQUEST_START[] = "\n+++++++++++ REQUEST +++++++++++";
constexpr char CAPIO_LOG_SERVER_REQUEST_END[] = "~~~~~~~~~ END REQUEST ~~~~~~~~~\n";

// Server - Warning banners
constexpr char CAPIO_LOG_SERVER_CLI_LOGGING_ENABLED_WARNING[5][80] = {
constexpr char CAPIO_LOG_SERVER_CLI_LOGGING_ENABLED_WARNING[6][80] = {
"\033[1;33m|==================================================================|\033[0m",
"\033[1;33m| you are running a build of CAPIO with logging enabled. |\033[0m",
"\033[1;33m| this will have impact on performance. you should recompile CAPIO |\033[0m",
"\033[1;33m| with -DCAPIO_LOG=FALSE |\033[0m",
"\033[1;33m|==================================================================|\033[0m"};
"\033[1;33m|==================================================================|\033[0m",
""};

constexpr char CAPIO_LOG_SERVER_CLI_CONT_ON_ERR_WARNING[7][80] = {
constexpr char CAPIO_LOG_SERVER_CLI_CONT_ON_ERR_WARNING[8][80] = {
"\033[1;31m|==================================================================|\033[0m",
"\033[1;31m| you are running CAPIO with --continue-on-error |\033[0m",
"\033[1;31m| This is extremely dangerous as CAPIO server will continue |\033[0m",
"\033[1;31m| its execution even if it should terminate. |\033[0m",
"\033[1;31m| |\033[0m",
"\033[1;31m| USE IT AT YOUR OWN RISK |\033[0m",
"\033[1;31m|==================================================================|\033[0m"};
"\033[1;31m|==================================================================|\033[0m",
""};

// CAPIO server argument parser
constexpr char CAPIO_SERVER_ARG_PARSER_PRE[] =
Expand Down Expand Up @@ -146,11 +127,4 @@ constexpr char CAPIO_SERVER_ARG_PARSER_CONFIG_BACKEND_HELP[] =
"Backend used in CAPIO. The value [backend] can be one of the following implemented backends: "
"\n\t> mpi \n\t> mpisync \n\t> none (default)";

// Cli pre messages
constexpr char CAPIO_LOG_SERVER_CLI_LEVEL_RESET[] = "\033[0m";
constexpr char CAPIO_LOG_SERVER_CLI_LEVEL_STATUS[] = "\033[1;34m";
constexpr char CAPIO_LOG_SERVER_CLI_LEVEL_INFO[] = "\033[1;32m";
constexpr char CAPIO_LOG_SERVER_CLI_LEVEL_WARNING[] = "\033[1;33m";
constexpr char CAPIO_LOG_SERVER_CLI_LEVEL_ERROR[] = "\033[1;31m";

#endif // CAPIO_COMMON_CONSTANTS_HPP
43 changes: 16 additions & 27 deletions capio/common/env.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
#include <cstdlib>
#include <filesystem>
#include <iostream>

#include <sys/stat.h>

#include "common/constants.hpp"
#include "common/syscall.hpp"
#include "logger.hpp"

#include <calf/StdOutLogger.h>

#ifdef __CAPIO_POSIX
#include "calf/SyscallLogger.h"
#else
#include "calf/StlLogger.h"
#endif

// TODO: remove forward declaration of function by splitting into header and impl. capio/common
inline bool is_forbidden_path(const std::string_view &path);
Expand All @@ -26,19 +33,19 @@ inline const std::filesystem::path &get_capio_dir() {

if (val == nullptr) {

std::cout << "\n"
<< CAPIO_LOG_SERVER_CLI_LEVEL_ERROR << "Fatal: CAPIO_DIR not provided!"
<< std::endl;
#ifndef __CAPIO_POSIX
CALF_PRINT_COLOR(CALF_CLI_LEVEL_ERROR, "CAPIO_DIR not provided");
#endif
ERR_EXIT("Fatal: CAPIO_DIR not provided!");

} else {

const char *realpath_res = capio_realpath(val, buf.get());
if (realpath_res == nullptr) {
std::cout << "\n"
<< CAPIO_LOG_SERVER_CLI_LEVEL_ERROR
<< "Fatal: CAPIO_DIR set, but folder does not exists on filesystem!"
<< std::endl;
#ifndef __CAPIO_POSIX
CALF_PRINT_COLOR(CALF_CLI_LEVEL_ERROR,
"Fatal: CAPIO_DIR set, but folder does not exists on filesystem!");
#endif
ERR_EXIT("error CAPIO_DIR: directory %s does not "
"exist. [buf=%s]",
val, buf.get());
Expand Down Expand Up @@ -91,24 +98,6 @@ inline long get_cache_line_size() {
return data_bufs_count;
}

inline int get_capio_log_level() {
static int level = -2;
if (level == -2) {
char *log_level = std::getenv("CAPIO_LOG_LEVEL");
if (log_level == nullptr) {
level = 0;
} else {
auto [ptr, ec] = std::from_chars(log_level, log_level + strlen(log_level), level);
if (ec != std::errc()) {
std::cout << CAPIO_LOG_SERVER_CLI_LEVEL_WARNING << "invalid CAPIO_LOG_LEVEL value"
<< std::endl;
level = 0;
}
}
}
return level;
}

inline std::string get_capio_workflow_name() {
static std::string name;
if (name.empty()) {
Expand Down
7 changes: 6 additions & 1 deletion capio/common/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

#include <sys/stat.h>

#include "common/logger.hpp"
#ifdef __CAPIO_POSIX
#include "calf/SyscallLogger.h"
#else
#include "calf/StlLogger.h"
#endif

#include "common/syscall.hpp"
#include "env.hpp"

Expand Down
Loading
Loading