-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tobias Pisani
committed
Dec 12, 2021
1 parent
45edb09
commit d93e59f
Showing
13 changed files
with
139 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,11 @@ if (APPLE) | |
endif() | ||
|
||
# Download External Dependencies via CPM | ||
CPMAddPackage("gh:fmtlib/fmt#7.1.3") | ||
CPMAddPackage("gh:fmtlib/fmt#8.0.1") | ||
CPMAddPackage("gh:catchorg/[email protected]") | ||
CPMAddPackage("gh:Neargye/[email protected]") | ||
CPMAddPackage("gh:Naios/function2#4.1.0") | ||
CPMAddPackage("gh:gabime/[email protected]") | ||
|
||
# We're on version v0.3.0-123-gff67c1a which is not officially tagged in Github | ||
# so we're going to use the SHA directly. | ||
|
@@ -72,22 +73,6 @@ if (nlohmann_json_ADDED) | |
target_include_directories(nlohmann_json SYSTEM INTERFACE "${nlohmann_json_SOURCE_DIR}/include") | ||
endif() | ||
|
||
CPMAddPackage( | ||
NAME loguru | ||
GITHUB_REPOSITORY emilk/loguru | ||
VERSION 2.1.0 | ||
DOWNLOAD_ONLY YES | ||
GIT_SHALLOW ON | ||
) | ||
|
||
if (loguru_ADDED) | ||
add_library(loguru "${loguru_SOURCE_DIR}/loguru.cpp") | ||
target_compile_definitions(loguru PUBLIC "-DLOGURU_USE_FMTLIB=1") | ||
target_link_libraries(loguru PUBLIC fmt) | ||
#target_link_libraries(loguru PUBLIC execinfo) | ||
target_include_directories(loguru SYSTEM PUBLIC "${loguru_SOURCE_DIR}") | ||
endif() | ||
|
||
CPMAddPackage( | ||
NAME nanobench | ||
VERSION 4.0.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#! /bin/bash | ||
|
||
ip=$1; shift | ||
binary=${1:-otto}; shift | ||
|
||
builddir=oe-workdir/otto-core-1.0.0+git999 | ||
|
||
sshargs="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR" | ||
|
||
_msg() { | ||
tput setaf 2 | ||
tput bold | ||
echo -n "==> " | ||
tput sgr0 | ||
tput bold | ||
# tput setaf 2 | ||
echo "$@" | ||
tput sgr0 | ||
} | ||
|
||
_msg "Remounting rootfs read/write" | ||
ssh $sshargs root@$ip mount -o remount,rw /dev/root / | ||
_msg "Stopping OTTO core" | ||
ssh $sshargs root@$ip /etc/init.d/otto-core.sh stop | ||
_msg "Deploying..." | ||
scp $sshargs $builddir/bin/$binary root@$ip:/home/root/otto/bin/$binary | ||
_msg "Remounting rootfs readonly" | ||
ssh $sshargs root@$ip mount -o remount,ro /dev/root / | ||
_msg "Starting OTTO core" | ||
ssh $sshargs root@$ip /etc/init.d/otto-core.sh start | ||
_msg "Done!" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,32 @@ | ||
#include "logging.hpp" | ||
|
||
#include <spdlog/async.h> | ||
#include <spdlog/sinks/basic_file_sink.h> | ||
#include <spdlog/sinks/stdout_color_sinks.h> | ||
|
||
#include "lib/util/exception.hpp" | ||
|
||
namespace otto::logging { | ||
|
||
using namespace std::literals; | ||
|
||
void init(int argc, char* argv[], bool enable_console, const char* logFilePath) | ||
void init(const char* logFilePath) | ||
{ | ||
// std::string def_path = Application::current().data_dir / "log.txt"; | ||
if (logFilePath == nullptr) { | ||
// logFilePath = def_path.c_str(); | ||
} | ||
auto async_logger = spdlog::create_async<spdlog::sinks::stdout_color_sink_mt>("async_logger"); | ||
|
||
if (!enable_console) { | ||
loguru::g_stderr_verbosity = loguru::Verbosity_OFF; | ||
if (logFilePath != nullptr) { | ||
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(logFilePath, true); | ||
async_logger->sinks().push_back(file_sink); | ||
} | ||
|
||
char exc[] = "otto"; | ||
char* eptr[] = {exc, nullptr}; | ||
if (argc == 0) { | ||
argc = 1; | ||
argv = eptr; | ||
} | ||
|
||
loguru::init(argc, argv); | ||
if (logFilePath) loguru::add_file(logFilePath, loguru::Append, loguru::Verbosity_MAX); | ||
|
||
loguru::set_fatal_handler([](const loguru::Message& message) { | ||
if (message.prefix != "Signal: "sv) throw util::exception(std::string(message.prefix) + message.message); | ||
}); | ||
spdlog::set_default_logger(async_logger); | ||
spdlog::set_error_handler([](const std::string& message) { throw util::exception("{}", message); }); | ||
|
||
LOGI("Logging initialized"); | ||
} | ||
|
||
void set_thread_name(const std::string& name) | ||
{ | ||
pthread_setname_np(pthread_self(), name.c_str()); | ||
loguru::set_thread_name(name.c_str()); | ||
} | ||
} // namespace otto::logging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.