-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(logging): separate logging from main (#2110)
- Loading branch information
1 parent
8373a8b
commit 0aa4f06
Showing
50 changed files
with
161 additions
and
80 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
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,5 @@ | ||
logging | ||
======= | ||
|
||
.. doxygenfile:: logging.h | ||
:allow-dot-graphs: |
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* @file src/logging.cpp | ||
* @brief Logging implementation file for the Sunshine application. | ||
*/ | ||
|
||
// standard includes | ||
#include <iostream> | ||
|
||
// lib includes | ||
#include <boost/log/attributes/clock.hpp> | ||
#include <boost/log/common.hpp> | ||
#include <boost/log/expressions.hpp> | ||
#include <boost/log/sinks.hpp> | ||
#include <boost/log/sources/severity_logger.hpp> | ||
|
||
// local includes | ||
#include "logging.h" | ||
|
||
using namespace std::literals; | ||
|
||
namespace bl = boost::log; | ||
|
||
boost::shared_ptr<boost::log::sinks::asynchronous_sink<boost::log::sinks::text_ostream_backend>> sink; | ||
|
||
bl::sources::severity_logger<int> verbose(0); // Dominating output | ||
bl::sources::severity_logger<int> debug(1); // Follow what is happening | ||
bl::sources::severity_logger<int> info(2); // Should be informed about | ||
bl::sources::severity_logger<int> warning(3); // Strange events | ||
bl::sources::severity_logger<int> error(4); // Recoverable errors | ||
bl::sources::severity_logger<int> fatal(5); // Unrecoverable errors | ||
|
||
/** | ||
* @brief Flush the log. | ||
* | ||
* EXAMPLES: | ||
* ```cpp | ||
* log_flush(); | ||
* ``` | ||
*/ | ||
void | ||
log_flush() { | ||
sink->flush(); | ||
} | ||
|
||
/** | ||
* @brief Print help to stdout. | ||
* @param name The name of the program. | ||
* | ||
* EXAMPLES: | ||
* ```cpp | ||
* print_help("sunshine"); | ||
* ``` | ||
*/ | ||
void | ||
print_help(const char *name) { | ||
std::cout | ||
<< "Usage: "sv << name << " [options] [/path/to/configuration_file] [--cmd]"sv << std::endl | ||
<< " Any configurable option can be overwritten with: \"name=value\""sv << std::endl | ||
<< std::endl | ||
<< " Note: The configuration will be created if it doesn't exist."sv << std::endl | ||
<< std::endl | ||
<< " --help | print help"sv << std::endl | ||
<< " --creds username password | set user credentials for the Web manager"sv << std::endl | ||
<< " --version | print the version of sunshine"sv << std::endl | ||
<< std::endl | ||
<< " flags"sv << std::endl | ||
<< " -0 | Read PIN from stdin"sv << std::endl | ||
<< " -1 | Do not load previously saved state and do retain any state after shutdown"sv << std::endl | ||
<< " | Effectively starting as if for the first time without overwriting any pairings with your devices"sv << std::endl | ||
<< " -2 | Force replacement of headers in video stream"sv << std::endl | ||
<< " -p | Enable/Disable UPnP"sv << std::endl | ||
<< std::endl; | ||
} |
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,27 @@ | ||
/** | ||
* @file src/logging.h | ||
* @brief Logging header file for the Sunshine application. | ||
*/ | ||
|
||
// macros | ||
#pragma once | ||
|
||
// lib includes | ||
#include <boost/log/common.hpp> | ||
#include <boost/log/sinks.hpp> | ||
|
||
extern boost::shared_ptr<boost::log::sinks::asynchronous_sink<boost::log::sinks::text_ostream_backend>> sink; | ||
using text_sink = boost::log::sinks::asynchronous_sink<boost::log::sinks::text_ostream_backend>; | ||
|
||
extern boost::log::sources::severity_logger<int> verbose; | ||
extern boost::log::sources::severity_logger<int> debug; | ||
extern boost::log::sources::severity_logger<int> info; | ||
extern boost::log::sources::severity_logger<int> warning; | ||
extern boost::log::sources::severity_logger<int> error; | ||
extern boost::log::sources::severity_logger<int> fatal; | ||
|
||
// functions | ||
void | ||
log_flush(); | ||
void | ||
print_help(const char *name); |
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,6 +1,7 @@ | ||
#include "nvenc_base.h" | ||
|
||
#include "src/config.h" | ||
#include "src/logging.h" | ||
#include "src/utility.h" | ||
|
||
namespace { | ||
|
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,3 +1,5 @@ | ||
#include "src/logging.h" | ||
|
||
#ifdef _WIN32 | ||
#include "nvenc_d3d11.h" | ||
|
||
|
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,3 +1,5 @@ | ||
#include <cassert> | ||
|
||
#include "nvenc_utils.h" | ||
|
||
namespace nvenc { | ||
|
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
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
Oops, something went wrong.