-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added option to disable exceptions, add backend worker error handler,…
- Loading branch information
Showing
39 changed files
with
452 additions
and
101 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
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,28 @@ | ||
/** | ||
* Using std::chrono clock instead of the default rdtsc clock | ||
*/ | ||
#define QUILL_CHRONO_CLOCK | ||
|
||
#include "quill/Quill.h" | ||
#include <iostream> | ||
|
||
/** | ||
* Test with random configuration options for the backend thread | ||
* @return | ||
*/ | ||
|
||
int main() | ||
{ | ||
// Set a custom error handler to handler exceptions | ||
quill::set_backend_worker_error_handler([](std::string const& s) { std::cout << s << std::endl; }); | ||
|
||
// Setting to an invalid CPU. When we call quill::start() our error handler will be invoked and an error will be logged | ||
quill::config::set_backend_thread_cpu_affinity(static_cast<uint16_t>(321312)); | ||
|
||
quill::config::set_backend_thread_name("example_thread"); | ||
|
||
// Start the logging backend thread | ||
quill::start(); | ||
|
||
LOG_INFO(quill::get_logger(), "{} {}", "Hello", "World!"); | ||
} |
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,58 @@ | ||
/** | ||
* Copyright(c) 2020-present, Odysseas Georgoudis & quill contributors. | ||
* Distributed under the MIT License (http://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "quill/TweakMe.h" | ||
|
||
#include "quill/detail/misc/Macros.h" | ||
#include <exception> | ||
#include <string> | ||
|
||
#if defined(QUILL_NO_EXCEPTIONS) | ||
#define QUILL_TRY if (true) | ||
#define QUILL_THROW(ex) QUILL_REQUIRE(false, ex.what()) | ||
#define QUILL_CATCH(x) if (false) | ||
#define QUILL_CATCH_ALL() if (false) | ||
#else | ||
#define QUILL_TRY try | ||
#define QUILL_THROW(ex) throw(ex) | ||
#define QUILL_CATCH(x) catch (x) | ||
#define QUILL_CATCH_ALL() catch (...) | ||
#endif | ||
|
||
namespace quill | ||
{ | ||
/** | ||
* custom exception | ||
*/ | ||
class QuillError : public std::exception | ||
{ | ||
public: | ||
explicit QuillError(std::string s) : _error(std::move(s)) {} | ||
explicit QuillError(char const* s) : _error(s) {} | ||
|
||
QuillError(QuillError const& other) noexcept : _error(other._error) {} | ||
|
||
QuillError& operator=(const QuillError& other) noexcept | ||
{ | ||
// check for self-assignment | ||
if (&other == this) | ||
{ | ||
return *this; | ||
} | ||
_error = other._error; | ||
return *this; | ||
} | ||
|
||
~QuillError() override = default; | ||
|
||
char const* what() const noexcept override { return _error.data(); } | ||
|
||
private: | ||
std::string _error; | ||
}; | ||
|
||
} // namespace quill |
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.