|
15 | 15 | * You should have received a copy of the GNU Affero General Public License
|
16 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 | 17 | *
|
18 |
| -* Copyright (C) 2017 Michael Lee(李登淳) |
| 18 | +* Copyright (C) 2018 Michael Lee(李登淳) |
19 | 19 |
|
20 | 20 | * Github: https://github.com/mikecovlee
|
21 | 21 | */
|
@@ -131,49 +131,55 @@ namespace darwin {
|
131 | 131 | };
|
132 | 132 |
|
133 | 133 | #ifndef DARWIN_DISABLE_LOG
|
| 134 | + |
134 | 135 | class debugger final {
|
135 | 136 | static outfs out;
|
136 | 137 | public:
|
137 | 138 | #ifdef DARWIN_STRICT_CHECK
|
138 | 139 | static constexpr bool strict=true;
|
139 | 140 | #else
|
140 |
| - static constexpr bool strict=false; |
| 141 | + static constexpr bool strict = false; |
141 | 142 | #endif
|
142 | 143 | #ifdef DARWIN_IGNORE_WARNING
|
143 | 144 | static constexpr bool ignore=true;
|
144 | 145 | #else
|
145 |
| - static constexpr bool ignore=false; |
| 146 | + static constexpr bool ignore = false; |
146 | 147 | #endif
|
147 |
| - static void log(const char* file,int line,const char* func,const char* msg) |
| 148 | + |
| 149 | + static void log(const char *file, int line, const char *func, const char *msg) |
148 | 150 | {
|
149 |
| - if(!out.usable()) |
| 151 | + if (!out.usable()) |
150 | 152 | out.open("./darwin_runtime.log");
|
151 |
| - out.printf("[Darwin Log(%ums)]:In function \"%s\"(%s:%d):%s\n",timer::time(),func,file,line,msg); |
| 153 | + out.printf("[Darwin Log(%ums)]:In function \"%s\"(%s:%d):%s\n", timer::time(), func, file, line, msg); |
152 | 154 | }
|
153 |
| - static void warning(const char* file,int line,const char* func,const char* msg) |
| 155 | + |
| 156 | + static void warning(const char *file, int line, const char *func, const char *msg) |
154 | 157 | {
|
155 |
| - if(ignore) |
| 158 | + if (ignore) |
156 | 159 | return;
|
157 |
| - if(!out.usable()) |
| 160 | + if (!out.usable()) |
158 | 161 | out.open("./darwin_runtime.log");
|
159 |
| - out.printf("[Darwin Warning(%ums)]:In function \"%s\"(%s:%d):%s\n",timer::time(),func,file,line,msg); |
160 |
| - if(strict) { |
| 162 | + out.printf("[Darwin Warning(%ums)]:In function \"%s\"(%s:%d):%s\n", timer::time(), func, file, line, msg); |
| 163 | + if (strict) { |
161 | 164 | out.flush();
|
162 | 165 | std::terminate();
|
163 | 166 | }
|
164 | 167 | }
|
165 |
| - static void error(const char* file,int line,const char* func,const char* msg) |
| 168 | + |
| 169 | + static void error(const char *file, int line, const char *func, const char *msg) |
166 | 170 | {
|
167 |
| - out.printf("[Darwin Error(%ums)]:In function \"%s\"(%s:%d):%s\n",timer::time(),func,file,line,msg); |
| 171 | + out.printf("[Darwin Error(%ums)]:In function \"%s\"(%s:%d):%s\n", timer::time(), func, file, line, msg); |
168 | 172 | out.flush();
|
169 | 173 | std::terminate();
|
170 | 174 | }
|
171 |
| - static void log_path(const char* path) |
| 175 | + |
| 176 | + static void log_path(const char *path) |
172 | 177 | {
|
173 | 178 | out.close();
|
174 | 179 | out.open(path);
|
175 | 180 | }
|
176 | 181 | };
|
| 182 | + |
177 | 183 | outfs debugger::out;
|
178 | 184 | #endif
|
179 | 185 | }
|
|
0 commit comments