mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-09 12:28:13 -04:00
feat(logger): allow construction without explicit terminal / ostream
This commit is contained in:
parent
93a6979cb6
commit
1dbefd98c1
@ -101,6 +101,8 @@ struct logger_options {
|
|||||||
|
|
||||||
class stream_logger : public logger {
|
class stream_logger : public logger {
|
||||||
public:
|
public:
|
||||||
|
explicit stream_logger(logger_options const& options = {});
|
||||||
|
explicit stream_logger(std::ostream& os, logger_options const& options = {});
|
||||||
stream_logger(std::shared_ptr<terminal const> term, std::ostream& os,
|
stream_logger(std::shared_ptr<terminal const> term, std::ostream& os,
|
||||||
logger_options const& options = {});
|
logger_options const& options = {});
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include <dwarfs/logger.h>
|
#include <dwarfs/logger.h>
|
||||||
#include <dwarfs/terminal.h>
|
#include <dwarfs/terminal_ansi.h>
|
||||||
#include <dwarfs/util.h>
|
#include <dwarfs/util.h>
|
||||||
|
|
||||||
namespace dwarfs {
|
namespace dwarfs {
|
||||||
@ -105,6 +105,12 @@ std::string logger::all_level_names() {
|
|||||||
|
|
||||||
null_logger::null_logger() { set_policy<prod_logger_policy>(); }
|
null_logger::null_logger() { set_policy<prod_logger_policy>(); }
|
||||||
|
|
||||||
|
stream_logger::stream_logger(logger_options const& options)
|
||||||
|
: stream_logger(std::cerr, options) {}
|
||||||
|
|
||||||
|
stream_logger::stream_logger(std::ostream& os, logger_options const& options)
|
||||||
|
: stream_logger(std::make_shared<terminal_ansi>(), os, options) {}
|
||||||
|
|
||||||
stream_logger::stream_logger(std::shared_ptr<terminal const> term,
|
stream_logger::stream_logger(std::shared_ptr<terminal const> term,
|
||||||
std::ostream& os, logger_options const& logopts)
|
std::ostream& os, logger_options const& logopts)
|
||||||
: os_(os)
|
: os_(os)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user