This commit is contained in:
parent
bf29df39e9
commit
c631e5c4fe
|
@ -2,7 +2,7 @@
|
|||
:doctype: manpage
|
||||
:Author: tastytea
|
||||
:Email: tastytea@tastytea.de
|
||||
:Date: 2019-12-20
|
||||
:Date: 2019-12-24
|
||||
:Revision: 0.0.0
|
||||
:man source: mastorss
|
||||
:man manual: General Commands Manual
|
||||
|
@ -71,6 +71,18 @@ Example: `http_proxy="http://localhost:3128/" mastorss`
|
|||
| 9 | Unknown error.
|
||||
|===========================================================
|
||||
|
||||
== DEBUGGING
|
||||
|
||||
Define the variable `MASTORSS_DEBUG` to enable debug output.
|
||||
|
||||
.Debug mastorss while using the profile “example”.
|
||||
================================================================================
|
||||
[source,shell]
|
||||
--------------------------------------------------------------------------------
|
||||
MASTORSS_DEBUG=1 mastorss example
|
||||
--------------------------------------------------------------------------------
|
||||
================================================================================
|
||||
|
||||
== SEE ALSO
|
||||
|
||||
*curl*(1), *crontab*(1), *crontab*(5)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
include(GNUInstallDirs)
|
||||
|
||||
# The minimum versions should be in Debian oldstable, if possible.
|
||||
find_package(Boost 1.62 REQUIRED COMPONENTS system filesystem)
|
||||
find_package(Boost 1.62 REQUIRED COMPONENTS system filesystem log)
|
||||
find_package(jsoncpp 1.7 REQUIRED CONFIG)
|
||||
find_package(CURL 7.52 REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
@ -18,7 +18,12 @@ include_directories("${PROJECT_BINARY_DIR}")
|
|||
file(GLOB sources *.cpp)
|
||||
add_executable(mastorss ${sources})
|
||||
target_link_libraries(mastorss
|
||||
mastodon-cpp::mastodon-cpp Boost::system Boost::filesystem restclient-cpp)
|
||||
PRIVATE
|
||||
jsoncpp restclient-cpp mastodon-cpp::mastodon-cpp
|
||||
Boost::filesystem Boost::log)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(mastorss PRIVATE "BOOST_ALL_DYN_LINK=1")
|
||||
endif()
|
||||
install(TARGETS mastorss DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
|
||||
install(FILES watchwords.json
|
||||
|
|
|
@ -18,13 +18,15 @@
|
|||
#include "exceptions.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <restclient-cpp/connection.h>
|
||||
#include <restclient-cpp/restclient.h>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
using namespace mastorss;
|
||||
namespace mastorss
|
||||
{
|
||||
using std::string;
|
||||
using std::move;
|
||||
|
||||
|
@ -54,6 +56,7 @@ void Document::download()
|
|||
case 200:
|
||||
{
|
||||
_raw_doc = response.body;
|
||||
BOOST_LOG_TRIVIAL(debug) << "Downloaded feed: " << _uri;
|
||||
break;
|
||||
}
|
||||
case 301:
|
||||
|
@ -73,3 +76,4 @@ void Document::download()
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace mastorss
|
||||
|
|
21
src/main.cpp
21
src/main.cpp
|
@ -3,13 +3,21 @@
|
|||
#include "exceptions.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#include <boost/log/core.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/utility/setup/console.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
using namespace mastorss;
|
||||
using std::getenv;
|
||||
using std::cout;
|
||||
using std::cerr;
|
||||
using std::runtime_error;
|
||||
using std::string_view;
|
||||
using std::vector;
|
||||
|
||||
|
@ -40,7 +48,7 @@ void print_version()
|
|||
|
||||
void print_help(const string_view &command)
|
||||
{
|
||||
cerr << "Usage: " << command << " [--version] <profile>\n";
|
||||
cerr << "Usage: " << command << " [--version|--help] <profile>\n";
|
||||
}
|
||||
} // namespace mastorss
|
||||
|
||||
|
@ -48,6 +56,17 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
const vector<string_view> args(argv, argv + argc);
|
||||
|
||||
if (getenv("MASTORSS_DEBUG") == nullptr)
|
||||
{
|
||||
boost::log::core::get()->set_filter
|
||||
(boost::log::trivial::severity >= boost::log::trivial::info);
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::log::core::get()->set_filter
|
||||
(boost::log::trivial::severity >= boost::log::trivial::debug);
|
||||
}
|
||||
|
||||
if (args.size() == 1)
|
||||
{
|
||||
print_help(args[0]);
|
||||
|
|
Loading…
Reference in New Issue
Block a user