@@ -30,7 +30,9 @@ class Sink {
3030 std::ostream *ostream;
3131 logger::Level flush_level;
3232
33- Sink (std::string logger_name) : logger_name(logger_name) { flush_level = logger::Level::ERR; }
33+ Sink (std::string logger_name) : logger_name(logger_name) {
34+ flush_level = logger::Level::ERR;
35+ }
3436
3537 private:
3638 std::string logger_name;
@@ -45,20 +47,21 @@ class Sink {
4547 if (*(++fmt) == ' {' ) {
4648 *ostream << *fmt++;
4749 } else {
48- throw std::runtime_error (" No arguments provided and braces not escaped!" );
50+ throw std::runtime_error (
51+ " No arguments provided and braces not escaped!" );
4952 }
5053 } else if (*fmt == ' }' ) {
5154 if (*(++fmt) == ' }' ) {
5255 *ostream << *fmt++;
5356 } else {
54- throw std::runtime_error (" Closing curly brace not escaped!" );
57+ throw std::runtime_error (
58+ " Closing curly brace not escaped!" );
5559 }
5660 }
5761 }
5862 }
5963
60- template <typename Arg>
61- void format (const char *fmt, Arg &&arg) {
64+ template <typename Arg> void format (const char *fmt, Arg &&arg) {
6265 while (*fmt != ' \0 ' ) {
6366 while (*fmt != ' {' && *fmt != ' }' && *fmt != ' \0 ' ) {
6467 *ostream << *fmt++;
@@ -77,7 +80,8 @@ class Sink {
7780 if (*(++fmt) == ' }' ) {
7881 *ostream << *fmt++;
7982 } else {
80- throw std::runtime_error (" Closing curly brace not escaped!" );
83+ throw std::runtime_error (
84+ " Closing curly brace not escaped!" );
8185 }
8286 }
8387 }
@@ -104,7 +108,8 @@ class Sink {
104108 if (*(++fmt) == ' }' ) {
105109 *ostream << *fmt++;
106110 } else {
107- throw std::runtime_error (" Closing curly brace not escaped!" );
111+ throw std::runtime_error (
112+ " Closing curly brace not escaped!" );
108113 }
109114 }
110115 }
@@ -115,9 +120,12 @@ class Sink {
115120
116121class StdoutSink : public Sink {
117122 public:
118- StdoutSink (std::string logger_name) : Sink(logger_name) { this ->ostream = &std::cout; }
123+ StdoutSink (std::string logger_name) : Sink(logger_name) {
124+ this ->ostream = &std::cout;
125+ }
119126
120- StdoutSink (std::string logger_name, Level flush_lvl) : StdoutSink(logger_name) {
127+ StdoutSink (std::string logger_name, Level flush_lvl)
128+ : StdoutSink(logger_name) {
121129 this ->flush_level = flush_lvl;
122130 }
123131
@@ -126,9 +134,12 @@ class StdoutSink : public Sink {
126134
127135class StderrSink : public Sink {
128136 public:
129- StderrSink (std::string logger_name) : Sink(logger_name) { this ->ostream = &std::cerr; }
137+ StderrSink (std::string logger_name) : Sink(logger_name) {
138+ this ->ostream = &std::cerr;
139+ }
130140
131- StderrSink (std::string logger_name, Level flush_lvl) : StderrSink(logger_name) {
141+ StderrSink (std::string logger_name, Level flush_lvl)
142+ : StderrSink(logger_name) {
132143 this ->flush_level = flush_lvl;
133144 }
134145
@@ -137,7 +148,8 @@ class StderrSink : public Sink {
137148
138149class FileSink : public Sink {
139150 public:
140- FileSink (std::string logger_name, std::string file_path) : Sink(logger_name) {
151+ FileSink (std::string logger_name, std::string file_path)
152+ : Sink(logger_name) {
141153 ofstream = std::ofstream (file_path, std::ofstream::out);
142154 if (ofstream.rdstate () != std::ofstream::goodbit) {
143155 throw std::invalid_argument (
@@ -147,21 +159,25 @@ class FileSink : public Sink {
147159 this ->ostream = &ofstream;
148160 }
149161
150- FileSink (std::string logger_name, std::string file_path, Level flush_lvl) : FileSink(logger_name, file_path) {
162+ FileSink (std::string logger_name, std::string file_path, Level flush_lvl)
163+ : FileSink(logger_name, file_path) {
151164 this ->flush_level = flush_lvl;
152165 }
153166
154167 private:
155168 std::ofstream ofstream;
156169};
157170
158- inline std::unique_ptr<Sink> sink_from_str (std::string logger_name, std::string name, std::string file_path = " " ) {
171+ inline std::unique_ptr<Sink> sink_from_str (std::string logger_name,
172+ std::string name,
173+ std::string file_path = " " ) {
159174 if (name == " stdout" ) {
160175 return std::make_unique<logger::StdoutSink>(logger_name);
161176 } else if (name == " stderr" ) {
162177 return std::make_unique<logger::StderrSink>(logger_name);
163178 } else if (name == " file" && !file_path.empty ()) {
164- return std::make_unique<logger::FileSink>(logger_name, file_path.c_str ());
179+ return std::make_unique<logger::FileSink>(logger_name,
180+ file_path.c_str ());
165181 }
166182
167183 throw std::invalid_argument (
0 commit comments