Commit 726dd9e0 authored by Stefan Spettel's avatar Stefan Spettel

refact(smf): Use logger from common-src submodule

Signed-off-by: default avatarStefan Spettel <stefan.spettel@phine.tech>
parent 8bd9faed
...@@ -62,16 +62,69 @@ install_spdlog_from_git() { ...@@ -62,16 +62,69 @@ install_spdlog_from_git() {
fi fi
git clone $GIT_URL git clone $GIT_URL
cd spdlog && git checkout master cd spdlog && git checkout v1.11.0
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
mkdir _build && cd _build
$CMAKE -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DSPDLOG_FMT_EXTERNAL=ON -DSPDLOG_BUILD_SHARED=ON ..
make
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
# enable syslog, Useless (defined in SMF code)
sed -i '/#define SPDLOG_ENABLE_SYSLOG/s/^\/\///g' include/spdlog/tweakme.h
popd popd
rm -Rf $OPENAIRCN_DIR/build/ext/spdlog/_build
fi fi
echo "spdlog installation complete" echo "spdlog installation complete"
return 0 return 0
} }
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_fmt_from_git() {
echo "Starting to install fmt"
if [ $1 -eq 0 ]; then
read -p "Do you want to install fmt? <y/N> " prompt
OPTION=""
else
prompt='y'
OPTION="-y"
fi
if [ $2 -eq 0 ]; then
debug=0
else
debug=1
fi
if [[ $prompt =~ [yY](es)* ]]
then
GIT_URL=https://github.com/fmtlib/fmt/
echo "Install fmt from $GIT_URL"
pushd $OPENAIRCN_DIR/build/ext
echo "Downloading fmt"
if [[ $OPTION =~ -[yY](es)* ]]
then
$SUDO rm -rf fmt
fi
git clone $GIT_URL
cd fmt && git checkout 9.0.0
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
mkdir _build && cd _build
$CMAKE -G "Unix Makefiles" -DFMT_TEST=OFF -DBUILD_SHARED_LIBS=TRUE ..
make
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd
rm -Rf $OPENAIRCN_DIR/build/ext/fmt/_build
fi
echo "fmt installation complete"
return 0
}
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script) #arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries) #arg2 is debug (0 or 1) (install debug libraries)
...@@ -263,6 +316,55 @@ install_nghttp2_from_git() { ...@@ -263,6 +316,55 @@ install_nghttp2_from_git() {
return 0 return 0
} }
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_libyaml_cpp_from_git() {
# For Ubuntu 2x and RHEL we should install from repo.
echo "Starting to install libyaml_cpp"
if [ $1 -eq 0 ]; then
read -p "Do you want to install yaml_cpp ? <y/N> " prompt
OPTION=""
else
prompt='y'
OPTION="-y"
fi
if [ $2 -eq 0 ]; then
debug=0
else
debug=1
fi
if [[ $prompt =~ [yY](es)* ]]
then
GIT_URL=https://github.com/jbeder/yaml-cpp.git
echo "Install yaml-cpp from $GIT_URL"
pushd $OPENAIRCN_DIR/build/ext
echo "Downloading yaml-cpp"
if [[ $OPTION =~ -[yY](es)* ]]
then
$SUDO rm -rf yaml-cpp
fi
git clone $GIT_URL
cd yaml-cpp && git checkout master
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
mkdir _build && cd _build
$CMAKE -G "Unix Makefiles" -DYAML_BUILD_SHARED_LIBS=on -DYAML_CPP_BUILD_TESTS=off ..
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
make
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd
rm -Rf $OPENAIRCN_DIR/build/ext/yaml-cpp/_build
fi
echo "yaml-cpp installation complete"
return 0
}
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script) #arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries) #arg2 is debug (0 or 1) (install debug libraries)
...@@ -400,6 +502,9 @@ check_install_smf_deps() { ...@@ -400,6 +502,9 @@ check_install_smf_deps() {
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
echo "distro libs installation complete" echo "distro libs installation complete"
install_fmt_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
install_spdlog_from_git $1 $2 install_spdlog_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
...@@ -412,6 +517,23 @@ check_install_smf_deps() { ...@@ -412,6 +517,23 @@ check_install_smf_deps() {
install_nghttp2_from_git $1 $2 install_nghttp2_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
if [[ $OS_DISTRO == "ubuntu" ]]; then
case "$(get_distribution_release)" in
"ubuntu18.04")
install_libyaml_cpp_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret
;;
"ubuntu20.04")
$SUDO $INSTALLER install $OPTION libyaml-cpp0.6 libyaml-cpp-dev
;;
"ubuntu22.04")
$SUDO $INSTALLER install $OPTION libyaml-cpp0.7 libyaml-cpp-dev
;;
esac
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
$SUDO $INSTALLER install $OPTION yaml-cpp yaml-cpp-devel
fi
$SUDO ldconfig $SUDO ldconfig
return 0 return 0
} }
......
...@@ -31,6 +31,12 @@ set (OPENAIRCN_DIR $ENV{OPENAIRCN_DIR}) ...@@ -31,6 +31,12 @@ set (OPENAIRCN_DIR $ENV{OPENAIRCN_DIR})
set (BUILD_TOP_DIR ${OPENAIRCN_DIR}/build) set (BUILD_TOP_DIR ${OPENAIRCN_DIR}/build)
set (SRC_TOP_DIR $ENV{OPENAIRCN_DIR}/src) set (SRC_TOP_DIR $ENV{OPENAIRCN_DIR}/src)
set (NF_TARGET_LIB SMF)
set (NF_TARGET smf)
set (NF_TARGET_API_LIB SMF_API)
set (MOUNTED_COMMON ${SOURCE_TOP_DIR}/oai-cn5g-common-src)
include(${CMAKE_CURRENT_SOURCE_DIR}/../../src/oai_smf/CMakeLists.txt) include(${CMAKE_CURRENT_SOURCE_DIR}/../../src/oai_smf/CMakeLists.txt)
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/smf_app ${CMAKE_CURRENT_BINARY_DIR}/smf_app) ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/smf_app ${CMAKE_CURRENT_BINARY_DIR}/smf_app)
...@@ -131,6 +131,8 @@ COPY --from=oai-smf-builder \ ...@@ -131,6 +131,8 @@ COPY --from=oai-smf-builder \
/usr/local/lib64/libpistache.so.0 \ /usr/local/lib64/libpistache.so.0 \
/usr/local/lib/libnghttp2_asio.so \ /usr/local/lib/libnghttp2_asio.so \
/usr/local/lib/libnghttp2_asio.so.1 \ /usr/local/lib/libnghttp2_asio.so.1 \
/usr/local/lib64/libspdlog.so \
/usr/local/lib64/libfmt.so \
/openair-smf/build/smf/build/nas/libNAS.so \ /openair-smf/build/smf/build/nas/libNAS.so \
/usr/lib64/ /usr/lib64/
......
...@@ -55,8 +55,7 @@ COPY ./build/cmake_modules /openair-smf/cmake_modules ...@@ -55,8 +55,7 @@ COPY ./build/cmake_modules /openair-smf/cmake_modules
# Installing all the needed libraries/packages to build and run SMF # Installing all the needed libraries/packages to build and run SMF
WORKDIR /openair-smf/build/scripts WORKDIR /openair-smf/build/scripts
RUN ./build_smf --install-deps --force && \ RUN ./build_smf --install-deps --force
cp -Rf /openair-smf/build/ext /openair-smf-ext-ref
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# BUILDER IMAGE # BUILDER IMAGE
...@@ -127,6 +126,7 @@ COPY --from=oai-smf-builder \ ...@@ -127,6 +126,7 @@ COPY --from=oai-smf-builder \
/usr/local/lib/libnghttp2.so.14 \ /usr/local/lib/libnghttp2.so.14 \
/usr/local/lib/libnghttp2_asio.so.1 \ /usr/local/lib/libnghttp2_asio.so.1 \
/usr/local/lib/libpistache.so \ /usr/local/lib/libpistache.so \
/usr/local/lib/libfmt.so \
/openair-smf/build/smf/build/nas/libNAS.so \ /openair-smf/build/smf/build/nas/libNAS.so \
# Ubuntu 18 --> boost 67 will be copied # Ubuntu 18 --> boost 67 will be copied
/usr/lib/libboost_system.so.1.* \ /usr/lib/libboost_system.so.1.* \
......
...@@ -42,7 +42,7 @@ include_directories(${SRC_TOP_DIR}/nas/mm/msg) ...@@ -42,7 +42,7 @@ include_directories(${SRC_TOP_DIR}/nas/mm/msg)
include_directories(${SRC_TOP_DIR}/ngap/asn1c) include_directories(${SRC_TOP_DIR}/ngap/asn1c)
include_directories(${SRC_TOP_DIR}/ngap/ies) include_directories(${SRC_TOP_DIR}/ngap/ies)
include_directories(${SRC_TOP_DIR}/udp) include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include) include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger)
file(GLOB SMF_API_SERVER_src_files file(GLOB SMF_API_SERVER_src_files
${SMF_API_SERVER_DIR}/smf-http2-server.cpp ${SMF_API_SERVER_DIR}/smf-http2-server.cpp
......
...@@ -25,11 +25,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/nas) ...@@ -25,11 +25,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/nas)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ngap) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ngap)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common/utils) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common/utils)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger)
add_library(3GPP_COMMON_TYPES STATIC
${CMAKE_CURRENT_SOURCE_DIR}/logger.cpp
)
/*
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "logger.hpp"
#include "spdlog/sinks/syslog_sink.h"
#include <iostream>
#include <sstream>
#include <string>
#include <memory>
Logger* Logger::m_singleton = NULL;
void Logger::_init(
const char* app, const bool log_stdout, bool const log_rot_file) {
int num_sinks = 0;
spdlog::set_async_mode(2048);
#if TRACE_IS_ON
spdlog::level::level_enum llevel = spdlog::level::trace;
#elif DEBUG_IS_ON
spdlog::level::level_enum llevel = spdlog::level::debug;
#elif INFO_IS_ON
spdlog::level::level_enum llevel = spdlog::level::info;
#else
spdlog::level::level_enum llevel = spdlog::level::warn;
#endif
if (log_stdout) {
std::string filename = fmt::format("./{}.log", app);
m_sinks.push_back(
std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>());
m_sinks[num_sinks++].get()->set_level(llevel);
}
if (log_rot_file) {
std::string filename = fmt::format("./{}.log", app);
m_sinks.push_back(std::make_shared<spdlog::sinks::rotating_file_sink_mt>(
filename, 5 * 1024 * 1024, 3));
m_sinks[num_sinks++].get()->set_level(llevel);
}
std::stringstream ss;
ss << "[%Y-%m-%dT%H:%M:%S.%f] [" << app << "] [%n] [%l] %v";
m_async_cmd = new _Logger("async_c", m_sinks, ss.str().c_str());
m_itti = new _Logger("itti ", m_sinks, ss.str().c_str());
m_smf_app = new _Logger("smf_app", m_sinks, ss.str().c_str());
m_system = new _Logger("system ", m_sinks, ss.str().c_str());
m_udp = new _Logger("udp ", m_sinks, ss.str().c_str());
m_pfcp = new _Logger("pfcp ", m_sinks, ss.str().c_str());
m_pfcp_switch = new _Logger("pfcp_sw ", m_sinks, ss.str().c_str());
m_smf_n1 = new _Logger("smf_n1 ", m_sinks, ss.str().c_str());
m_smf_n2 = new _Logger("smf_n2 ", m_sinks, ss.str().c_str());
m_smf_n4 = new _Logger("smf_n4 ", m_sinks, ss.str().c_str());
m_smf_n7 = new _Logger("smf_n7 ", m_sinks, ss.str().c_str());
m_smf_sbi = new _Logger("smf_sbi", m_sinks, ss.str().c_str());
m_smf_api_server = new _Logger("sbi_srv", m_sinks, ss.str().c_str());
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
_Logger::_Logger(
const char* category, std::vector<spdlog::sink_ptr>& sinks,
const char* pattern)
: m_log(category, sinks.begin(), sinks.end()) {
m_log.set_pattern(pattern);
#if TRACE_IS_ON
m_log.set_level(spdlog::level::trace);
#elif DEBUG_IS_ON
m_log.set_level(spdlog::level::debug);
#elif INFO_IS_ON
m_log.set_level(spdlog::level::info);
#else
m_log.set_level(spdlog::level::warn);
#endif
}
void _Logger::trace(const char* format, ...) {
#if TRACE_IS_ON
va_list args;
va_start(args, format);
log(_ltTrace, format, args);
va_end(args);
#endif
}
void _Logger::debug(const char* format, ...) {
#if DEBUG_IS_ON
va_list args;
va_start(args, format);
log(_ltDebug, format, args);
va_end(args);
#endif
}
void _Logger::info(const char* format, ...) {
#if INFO_IS_ON
va_list args;
va_start(args, format);
log(_ltInfo, format, args);
va_end(args);
#endif
}
void _Logger::startup(const char* format, ...) {
va_list args;
va_start(args, format);
log(_ltStartup, format, args);
va_end(args);
}
void _Logger::warn(const char* format, ...) {
va_list args;
va_start(args, format);
log(_ltWarn, format, args);
va_end(args);
}
void _Logger::error(const char* format, ...) {
va_list args;
va_start(args, format);
log(_ltError, format, args);
va_end(args);
}
void _Logger::log(_LogType lt, const char* format, va_list& args) {
char buffer[2048];
vsnprintf(buffer, sizeof(buffer), format, args);
switch (lt) {
case _ltTrace:
m_log.trace(buffer);
break;
case _ltDebug:
m_log.debug(buffer);
break;
case _ltInfo:
m_log.info(buffer);
break;
case _ltStartup:
m_log.warn(buffer);
break;
case _ltWarn:
m_log.error(buffer);
break;
case _ltError:
m_log.critical(buffer);
break;
}
}
/* /*
* Copyright (c) 2017 Sprint * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * http://www.openairinterface.org/?page_id=698
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/ */
#ifndef __LOGGER_H /*! \file logger.hpp
#define __LOGGER_H \brief
\author Stefan Spettel
\company OpenAirInterface Software Alliance
\date 2022
\email: stefan.spettel@eurecom.fr
*/
#pragma once
#include "logger_base.hpp"
static const std::string SMF_APP = "smf_app";
static const std::string SMF_SBI = "smf_sbi";
static const std::string SYSTEM = "system ";
static const std::string UDP = "udp ";
static const std::string PFCP = "pfcp ";
static const std::string SMF_N4 = "smf_n4 ";
static const std::string SMF_N1 = "smf_n1 ";
static const std::string SMF_N2 = "smf_n2 ";
static const std::string SMF_N7 = "smf_n7 ";
static const std::string SMF_API_SERVER = "smf_api";
static const std::string ITTI = "itti ";
static const std::string ASYNC = "async ";
#include <cstdarg> class Logger {
#include <stdexcept> public:
#include <vector> static void init(
const std::string& name, bool log_stdout, bool log_rot_file) {
oai::logger::logger_registry::register_logger(
name, SMF_APP, log_stdout, log_rot_file);
oai::logger::logger_registry::register_logger(
name, SMF_SBI, log_stdout, log_rot_file);
oai::logger::logger_registry::register_logger(
name, SYSTEM, log_stdout, log_rot_file);
oai::logger::logger_registry::register_logger(
name, UDP, log_stdout, log_rot_file);
oai::logger::logger_registry::register_logger(
name, SMF_N1, log_stdout, log_rot_file);
oai::logger::logger_registry::register_logger(
name, SMF_N2, log_stdout, log_rot_file);
oai::logger::logger_registry::register_logger(
name, SMF_N4, log_stdout, log_rot_file);
oai::logger::logger_registry::register_logger(
name, SMF_N7, log_stdout, log_rot_file);
oai::logger::logger_registry::register_logger(
name, SMF_API_SERVER, log_stdout, log_rot_file);
oai::logger::logger_registry::register_logger(
name, PFCP, log_stdout, log_rot_file);
oai::logger::logger_registry::register_logger(
name, ITTI, log_stdout, log_rot_file);
oai::logger::logger_registry::register_logger(
name, ASYNC, log_stdout, log_rot_file);
}
#define SPDLOG_LEVEL_NAMES \ static const oai::logger::printf_logger& smf_app() {
{"trace", "debug", "info ", "start", "warn ", "error", "off "}; return oai::logger::logger_registry::get_logger(SMF_APP);
}
#define SPDLOG_ENABLE_SYSLOG static const oai::logger::printf_logger& smf_sbi() {
#include "spdlog/spdlog.h" return oai::logger::logger_registry::get_logger(SMF_SBI);
}
class LoggerException : public std::runtime_error { static const oai::logger::printf_logger& system() {
public: return oai::logger::logger_registry::get_logger(SYSTEM);
explicit LoggerException(const char* m) : std::runtime_error(m) {} }
explicit LoggerException(const std::string& m) : std::runtime_error(m) {}
};
class _Logger { static const oai::logger::printf_logger& udp() {
public: return oai::logger::logger_registry::get_logger(UDP);
_Logger( }
const char* category, std::vector<spdlog::sink_ptr>& sinks,
const char* pattern);
void trace(const char* format, ...);
void trace(const std::string& format, ...);
void debug(const char* format, ...);
void debug(const std::string& format, ...);
void info(const char* format, ...);
void info(const std::string& format, ...);
void startup(const char* format, ...);
void startup(const std::string& format, ...);
void warn(const char* format, ...);
void warn(const std::string& format, ...);
void error(const char* format, ...);
void error(const std::string& format, ...);
private:
_Logger();
enum _LogType { _ltTrace, _ltDebug, _ltInfo, _ltStartup, _ltWarn, _ltError };
void log(_LogType lt, const char* format, va_list& args);
spdlog::logger m_log;
};
class Logger { static const oai::logger::printf_logger& smf_n1() {
public: return oai::logger::logger_registry::get_logger(SMF_N1);
static void init(
const char* app, const bool log_stdout, const bool log_rot_file) {
singleton()._init(app, log_stdout, log_rot_file);
} }
static void init(
const std::string& app, const bool log_stdout, const bool log_rot_file) { static const oai::logger::printf_logger& smf_n2() {
init(app.c_str(), log_stdout, log_rot_file); return oai::logger::logger_registry::get_logger(SMF_N2);
}
static const oai::logger::printf_logger& smf_n4() {
return oai::logger::logger_registry::get_logger(SMF_N4);
} }
static _Logger& async_cmd() { return *singleton().m_async_cmd; } static const oai::logger::printf_logger& smf_n7() {
static _Logger& itti() { return *singleton().m_itti; } return oai::logger::logger_registry::get_logger(SMF_N7);
static _Logger& smf_app() { return *singleton().m_smf_app; }
static _Logger& system() { return *singleton().m_system; }
static _Logger& udp() { return *singleton().m_udp; }
static _Logger& pfcp() { return *singleton().m_pfcp; }
static _Logger& pfcp_switch() { return *singleton().m_pfcp_switch; }
static _Logger& smf_n1() { return *singleton().m_smf_n1; }
static _Logger& smf_n2() { return *singleton().m_smf_n2; }
static _Logger& smf_n4() { return *singleton().m_smf_n4; }
static _Logger& smf_n7() { return *singleton().m_smf_n7; }
static _Logger& smf_sbi() { return *singleton().m_smf_sbi; }
static _Logger& smf_api_server() { return *singleton().m_smf_api_server; }
private:
static Logger* m_singleton;
static Logger& singleton() {
if (!m_singleton) m_singleton = new Logger();
return *m_singleton;
} }
Logger() {} static const oai::logger::printf_logger& smf_api_server() {
~Logger() {} return oai::logger::logger_registry::get_logger(SMF_API_SERVER);
}
void _init(const char* app, const bool log_stdout, const bool log_rot_file); static const oai::logger::printf_logger& pfcp() {
return oai::logger::logger_registry::get_logger(PFCP);
}
std::vector<spdlog::sink_ptr> m_sinks; static const oai::logger::printf_logger& itti() {
return oai::logger::logger_registry::get_logger(ITTI);
}
std::string m_pattern; static const oai::logger::printf_logger& async_cmd() {
return oai::logger::logger_registry::get_logger(ASYNC);
}
_Logger* m_async_cmd;
_Logger* m_itti;
_Logger* m_smf_app;
_Logger* m_system;
_Logger* m_udp;
_Logger* m_pfcp;
_Logger* m_pfcp_switch;
_Logger* m_smf_n1;
_Logger* m_smf_n2;
_Logger* m_smf_n4;
_Logger* m_smf_n7;
_Logger* m_smf_sbi;
_Logger* m_smf_api_server;
}; };
\ No newline at end of file
#endif // __LOGGER_H
...@@ -36,7 +36,7 @@ include_directories(${SRC_TOP_DIR}/nas/sm) ...@@ -36,7 +36,7 @@ include_directories(${SRC_TOP_DIR}/nas/sm)
include_directories(${SRC_TOP_DIR}/nas/sm/msg) include_directories(${SRC_TOP_DIR}/nas/sm/msg)
#include_directories(${SRC_TOP_DIR}/nas/security) #include_directories(${SRC_TOP_DIR}/nas/security)
include_directories(${SRC_TOP_DIR}/ngap/asn1c) include_directories(${SRC_TOP_DIR}/ngap/asn1c)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include) include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger)
set(CN_UTILS_SRC STATIC set(CN_UTILS_SRC STATIC
${CMAKE_CURRENT_SOURCE_DIR}/3gpp_conversions.cpp ${CMAKE_CURRENT_SOURCE_DIR}/3gpp_conversions.cpp
......
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
*/ */
#include "thread_sched.hpp" #include "thread_sched.hpp"
using namespace oai::logger;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void util::thread_sched_params::apply( void util::thread_sched_params::apply(
const int task_id, _Logger& logger) const { const int task_id, const printf_logger& logger) const {
if (cpu_id >= 0) { if (cpu_id >= 0) {
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_SET(cpu_id, &cpuset); CPU_SET(cpu_id, &cpuset);
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#define FILE_THREAD_SCHED_HPP_SEEN #define FILE_THREAD_SCHED_HPP_SEEN
#include <sched.h> #include <sched.h>
#include "logger.hpp" #include "logger_base.hpp"
namespace util { namespace util {
...@@ -40,7 +40,7 @@ class thread_sched_params { ...@@ -40,7 +40,7 @@ class thread_sched_params {
int cpu_id; int cpu_id;
int sched_policy; int sched_policy;
int sched_priority; int sched_priority;
void apply(const int task_id, _Logger& logger) const; void apply(const int task_id, const oai::logger::printf_logger& logger) const;
}; };
} // namespace util } // namespace util
......
oai-cn5g-common-src @ 491a86ad
Subproject commit af4dfeb0b0da43016ce07ceec51596d967ab3351 Subproject commit 491a86adc338f4d6fad3e54f92b4f41adc836457
...@@ -289,7 +289,6 @@ include_directories(${SRC_TOP_DIR}/common/utils) ...@@ -289,7 +289,6 @@ include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/common/utils/bstr) include_directories(${SRC_TOP_DIR}/common/utils/bstr)
include_directories(${SRC_TOP_DIR}/pfcp) include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/udp) include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/api-server) include_directories(${SRC_TOP_DIR}/api-server)
include_directories(${SRC_TOP_DIR}/api-server/api) include_directories(${SRC_TOP_DIR}/api-server/api)
include_directories(${SRC_TOP_DIR}/api-server/impl) include_directories(${SRC_TOP_DIR}/api-server/impl)
...@@ -312,6 +311,8 @@ add_executable(smf ...@@ -312,6 +311,8 @@ add_executable(smf
${SRC_TOP_DIR}/itti/itti_msg.cpp ${SRC_TOP_DIR}/itti/itti_msg.cpp
) )
include(${SRC_TOP_DIR}/oai-cn5g-common-src/logger/logger.cmake)
IF(STATIC_LINKING) IF(STATIC_LINKING)
SET(CMAKE_EXE_LINKER_FLAGS "-static") SET(CMAKE_EXE_LINKER_FLAGS "-static")
SET_TARGET_PROPERTIES(smf PROPERTIES LINK_SEARCH_END_STATIC 1) SET_TARGET_PROPERTIES(smf PROPERTIES LINK_SEARCH_END_STATIC 1)
...@@ -320,4 +321,4 @@ IF(STATIC_LINKING) ...@@ -320,4 +321,4 @@ IF(STATIC_LINKING)
ENDIF(STATIC_LINKING) ENDIF(STATIC_LINKING)
target_link_libraries (smf ${ASAN} target_link_libraries (smf ${ASAN}
-Wl,--start-group CN_UTILS SMF UDP PFCP 3GPP_COMMON_TYPES SMF_API -lnettle ${NETTLE_LIBRARIES} ${CRYPTO_LIBRARIES} -lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS dl -Wl,--end-group pthread m rt config++ event boost_system boost_chrono pistache curl) -Wl,--start-group CN_UTILS SMF UDP PFCP SMF_API -lnettle ${NETTLE_LIBRARIES} ${CRYPTO_LIBRARIES} -lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto -lfmt -lspdlog NAS dl -Wl,--end-group pthread m rt config++ event boost_system boost_chrono pistache curl)
...@@ -27,7 +27,7 @@ include_directories(${SRC_TOP_DIR}/common/utils/bstr) ...@@ -27,7 +27,7 @@ include_directories(${SRC_TOP_DIR}/common/utils/bstr)
include_directories(${SRC_TOP_DIR}/oai_smf) include_directories(${SRC_TOP_DIR}/oai_smf)
include_directories(${SRC_TOP_DIR}/pfcp) include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/udp) include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include) include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger)
add_library(PFCP STATIC add_library(PFCP STATIC
3gpp_29.244.cpp 3gpp_29.244.cpp
......
...@@ -39,11 +39,11 @@ include_directories(${SRC_TOP_DIR}/nas/sm) ...@@ -39,11 +39,11 @@ include_directories(${SRC_TOP_DIR}/nas/sm)
include_directories(${SRC_TOP_DIR}/nas/sm/msg) include_directories(${SRC_TOP_DIR}/nas/sm/msg)
include_directories(${SRC_TOP_DIR}/nas/security) include_directories(${SRC_TOP_DIR}/nas/security)
include_directories(${SRC_TOP_DIR}/udp) include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/api-server/api) include_directories(${SRC_TOP_DIR}/api-server/api)
include_directories(${SRC_TOP_DIR}/api-server/impl) include_directories(${SRC_TOP_DIR}/api-server/impl)
include_directories(${SRC_TOP_DIR}/api-server/model) include_directories(${SRC_TOP_DIR}/api-server/model)
include_directories(${SRC_TOP_DIR}/api-server/) include_directories(${SRC_TOP_DIR}/api-server/)
include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger)
add_library (SMF STATIC add_library (SMF STATIC
smf_app.cpp smf_app.cpp
......
...@@ -725,7 +725,7 @@ void smf_app::handle_itti_msg( ...@@ -725,7 +725,7 @@ void smf_app::handle_itti_msg(
} break; } break;
default: { default: {
Logger::smf_app().warn("Unknown procedure type %d", m.procedure_type); Logger::smf_app().warn("Unknown procedure type %d", (int) m.procedure_type);
} }
} }
} }
......
...@@ -2936,7 +2936,7 @@ bool smf_context::handle_pdu_session_update_sm_context_request( ...@@ -2936,7 +2936,7 @@ bool smf_context::handle_pdu_session_update_sm_context_request(
} break; } break;
default: { default: {
Logger::smf_app().warn("Unknown N2 SM info type %d", n2_sm_info_type); Logger::smf_app().warn("Unknown N2 SM info type %d", (int) n2_sm_info_type);
} }
} // end switch } // end switch
...@@ -4211,8 +4211,8 @@ void smf_context::handle_ue_ip_change( ...@@ -4211,8 +4211,8 @@ void smf_context::handle_ue_ip_change(
Logger::smf_app().debug( Logger::smf_app().debug(
"Send request to N11 to triger FlexCN (Event " "Send request to N11 to triger FlexCN (Event "
"Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d", "Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %u, HTTP version %u",
supi, sp->get_pdu_session_id(), http_version); supi64, sp->get_pdu_session_id(), http_version);
std::vector<std::shared_ptr<smf_subscription>> subscriptions = {}; std::vector<std::shared_ptr<smf_subscription>> subscriptions = {};
smf_app_inst->get_ee_subscriptions( smf_app_inst->get_ee_subscriptions(
...@@ -4382,8 +4382,8 @@ void smf_context::handle_flexcn_event( ...@@ -4382,8 +4382,8 @@ void smf_context::handle_flexcn_event(
Logger::smf_app().debug( Logger::smf_app().debug(
"Send request to N11 to triger FlexCN (Event " "Send request to N11 to triger FlexCN (Event "
"Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d", "Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %u, HTTP version %u",
supi, sp->get_pdu_session_id(), http_version); supi64, sp->get_pdu_session_id(), http_version);
std::vector<std::shared_ptr<smf_subscription>> subscriptions = {}; std::vector<std::shared_ptr<smf_subscription>> subscriptions = {};
smf_app_inst->get_ee_subscriptions( smf_app_inst->get_ee_subscriptions(
...@@ -4518,8 +4518,8 @@ void smf_context::handle_pdusesest( ...@@ -4518,8 +4518,8 @@ void smf_context::handle_pdusesest(
Logger::smf_app().debug( Logger::smf_app().debug(
"Send request to N11 to triger PDU_SES_EST (Event " "Send request to N11 to triger PDU_SES_EST (Event "
"Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d", "Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %u, HTTP version %u",
supi, sp->get_pdu_session_id(), http_version); supi64, sp->get_pdu_session_id(), http_version);
std::vector<std::shared_ptr<smf_subscription>> subscriptions = {}; std::vector<std::shared_ptr<smf_subscription>> subscriptions = {};
smf_app_inst->get_ee_subscriptions( smf_app_inst->get_ee_subscriptions(
...@@ -5165,7 +5165,7 @@ void smf_context::send_pdu_session_update_response( ...@@ -5165,7 +5165,7 @@ void smf_context::send_pdu_session_update_response(
default: { default: {
Logger::smf_app().info( Logger::smf_app().info(
"Unknown session procedure type %d", session_procedure_type); "Unknown session procedure type %d", (int) session_procedure_type);
} }
} }
} else { } else {
......
...@@ -1253,7 +1253,7 @@ smf_procedure_code session_update_sm_context_procedure::run( ...@@ -1253,7 +1253,7 @@ smf_procedure_code session_update_sm_context_procedure::run(
default: { default: {
Logger::smf_app().error( Logger::smf_app().error(
"Update SM Context procedure: Unknown session management type %d", "Update SM Context procedure: Unknown session management type %d",
session_procedure_type); (int) session_procedure_type);
} }
} }
......
...@@ -25,7 +25,7 @@ include_directories(${SRC_TOP_DIR}/common/utils) ...@@ -25,7 +25,7 @@ include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/itti) include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/pfcp) include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/udp) include_directories(${SRC_TOP_DIR}/udp)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include) include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger)
add_library (UDP STATIC add_library (UDP STATIC
udp.cpp udp.cpp
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "endpoint.hpp" #include "endpoint.hpp"
#include "itti.hpp" #include "itti.hpp"
#include "thread_sched.hpp" #include "thread_sched.hpp"
#include "logger.hpp"
#include <arpa/inet.h> #include <arpa/inet.h>
#include <inttypes.h> #include <inttypes.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment