19
19
* format that string. For example:
20
20
*
21
21
* LOGD("This is a message");
22
- * LOGD("This is message number %d ", 10);
22
+ * LOGD("This is message number {:d} ", 10);
23
23
*/
24
24
#define LOGD (...) \
25
25
do \
36
36
* format that string. For example:
37
37
*
38
38
* LOGI("This is a message");
39
- * LOGI("This is message number %d ", 10);
39
+ * LOGI("This is message number {:d} ", 10);
40
40
*/
41
41
#define LOGI (...) \
42
42
do \
53
53
* format that string. For example:
54
54
*
55
55
* LOGW("This is a message");
56
- * LOGW("This is message number %d ", 10);
56
+ * LOGW("This is message number {:d} ", 10);
57
57
*/
58
58
#define LOGW (...) \
59
59
do \
71
71
* format that string. For example:
72
72
*
73
73
* LOGS("This is a message");
74
- * LOGS("This is message number %d ", 10);
74
+ * LOGS("This is message number {:d} ", 10);
75
75
*/
76
76
#define LOGS (...) \
77
77
do \
78
78
{ \
79
79
fly::Logger::get_default_logger ()->warn ( \
80
80
{__FILE__, __FUNCTION__, static_cast <std::uint32_t >(__LINE__)}, \
81
- FLY_FORMAT_STRING (__VA_ARGS__) " : %s " FLY_FORMAT_ARGS (__VA_ARGS__), \
81
+ FLY_FORMAT_STRING (__VA_ARGS__) " : {} " FLY_FORMAT_ARGS (__VA_ARGS__), \
82
82
fly::System::get_error_string ()); \
83
83
} while (0 )
84
84
89
89
* format that string. For example:
90
90
*
91
91
* LOGE("This is a message");
92
- * LOGE("This is message number %d ", 10);
92
+ * LOGE("This is message number {:d} ", 10);
93
93
*/
94
94
#define LOGE (...) \
95
95
do \
@@ -276,10 +276,14 @@ class Logger : public std::enable_shared_from_this<Logger>
276
276
* @param format The format string for the log point.
277
277
* @param args The variadic list of arguments to augment the format string with.
278
278
*/
279
- template <typename ... Args>
280
- void debug (const char *format, const Args &...args)
279
+ template <typename ... ParameterTypes>
280
+ inline void
281
+ debug (String::FormatString<ParameterTypes...> &&format, ParameterTypes &&...parameters)
281
282
{
282
- log (Log::Level::Debug, {}, String::format (format, args...));
283
+ debug (
284
+ {},
285
+ std::forward<String::FormatString<ParameterTypes...>>(format),
286
+ std::forward<ParameterTypes>(parameters)...);
283
287
}
284
288
285
289
/* *
@@ -291,10 +295,17 @@ class Logger : public std::enable_shared_from_this<Logger>
291
295
* @param format The format string for the log point.
292
296
* @param args The variadic list of arguments to augment the format string with.
293
297
*/
294
- template <typename ... Args>
295
- void debug (Log::Trace &&trace, const char *format, const Args &...args)
298
+ template <typename ... ParameterTypes>
299
+ inline void debug (
300
+ Log::Trace &&trace,
301
+ String::FormatString<ParameterTypes...> &&format,
302
+ ParameterTypes &&...parameters)
296
303
{
297
- log (Log::Level::Debug, std::move (trace), String::format (format, args...));
304
+ log (Log::Level::Debug,
305
+ std::move (trace),
306
+ String::format (
307
+ std::forward<String::FormatString<ParameterTypes...>>(format),
308
+ std::forward<ParameterTypes>(parameters)...));
298
309
}
299
310
300
311
/* *
@@ -305,10 +316,14 @@ class Logger : public std::enable_shared_from_this<Logger>
305
316
* @param format The format string for the log point.
306
317
* @param args The variadic list of arguments to augment the format string with.
307
318
*/
308
- template <typename ... Args>
309
- void info (const char *format, const Args &...args)
319
+ template <typename ... ParameterTypes>
320
+ inline void
321
+ info (String::FormatString<ParameterTypes...> &&format, ParameterTypes &&...parameters)
310
322
{
311
- log (Log::Level::Info, {}, String::format (format, args...));
323
+ info (
324
+ {},
325
+ std::forward<String::FormatString<ParameterTypes...>>(format),
326
+ std::forward<ParameterTypes>(parameters)...);
312
327
}
313
328
314
329
/* *
@@ -320,10 +335,17 @@ class Logger : public std::enable_shared_from_this<Logger>
320
335
* @param format The format string for the log point.
321
336
* @param args The variadic list of arguments to augment the format string with.
322
337
*/
323
- template <typename ... Args>
324
- void info (Log::Trace &&trace, const char *format, const Args &...args)
338
+ template <typename ... ParameterTypes>
339
+ inline void info (
340
+ Log::Trace &&trace,
341
+ String::FormatString<ParameterTypes...> &&format,
342
+ ParameterTypes &&...parameters)
325
343
{
326
- log (Log::Level::Info, std::move (trace), String::format (format, args...));
344
+ log (Log::Level::Info,
345
+ std::move (trace),
346
+ String::format (
347
+ std::forward<String::FormatString<ParameterTypes...>>(format),
348
+ std::forward<ParameterTypes>(parameters)...));
327
349
}
328
350
329
351
/* *
@@ -334,10 +356,14 @@ class Logger : public std::enable_shared_from_this<Logger>
334
356
* @param format The format string for the log point.
335
357
* @param args The variadic list of arguments to augment the format string with.
336
358
*/
337
- template <typename ... Args>
338
- void warn (const char *format, const Args &...args)
359
+ template <typename ... ParameterTypes>
360
+ inline void
361
+ warn (String::FormatString<ParameterTypes...> &&format, ParameterTypes &&...parameters)
339
362
{
340
- log (Log::Level::Warn, {}, String::format (format, args...));
363
+ warn (
364
+ {},
365
+ std::forward<String::FormatString<ParameterTypes...>>(format),
366
+ std::forward<ParameterTypes>(parameters)...);
341
367
}
342
368
343
369
/* *
@@ -349,10 +375,17 @@ class Logger : public std::enable_shared_from_this<Logger>
349
375
* @param format The format string for the log point.
350
376
* @param args The variadic list of arguments to augment the format string with.
351
377
*/
352
- template <typename ... Args>
353
- void warn (Log::Trace &&trace, const char *format, const Args &...args)
378
+ template <typename ... ParameterTypes>
379
+ inline void warn (
380
+ Log::Trace &&trace,
381
+ String::FormatString<ParameterTypes...> &&format,
382
+ ParameterTypes &&...parameters)
354
383
{
355
- log (Log::Level::Warn, std::move (trace), String::format (format, args...));
384
+ log (Log::Level::Warn,
385
+ std::move (trace),
386
+ String::format (
387
+ std::forward<String::FormatString<ParameterTypes...>>(format),
388
+ std::forward<ParameterTypes>(parameters)...));
356
389
}
357
390
358
391
/* *
@@ -363,10 +396,14 @@ class Logger : public std::enable_shared_from_this<Logger>
363
396
* @param format The format string for the log point.
364
397
* @param args The variadic list of arguments to augment the format string with.
365
398
*/
366
- template <typename ... Args>
367
- void error (const char *format, const Args &...args)
399
+ template <typename ... ParameterTypes>
400
+ inline void
401
+ error (String::FormatString<ParameterTypes...> &&format, ParameterTypes &&...parameters)
368
402
{
369
- log (Log::Level::Error, {}, String::format (format, args...));
403
+ error (
404
+ {},
405
+ std::forward<String::FormatString<ParameterTypes...>>(format),
406
+ std::forward<ParameterTypes>(parameters)...);
370
407
}
371
408
372
409
/* *
@@ -378,10 +415,17 @@ class Logger : public std::enable_shared_from_this<Logger>
378
415
* @param format The format string for the log point.
379
416
* @param args The variadic list of arguments to augment the format string with.
380
417
*/
381
- template <typename ... Args>
382
- void error (Log::Trace &&trace, const char *format, const Args &...args)
418
+ template <typename ... ParameterTypes>
419
+ inline void error (
420
+ Log::Trace &&trace,
421
+ String::FormatString<ParameterTypes...> &&format,
422
+ ParameterTypes &&...parameters)
383
423
{
384
- log (Log::Level::Error, std::move (trace), String::format (format, args...));
424
+ log (Log::Level::Error,
425
+ std::move (trace),
426
+ String::format (
427
+ std::forward<String::FormatString<ParameterTypes...>>(format),
428
+ std::forward<ParameterTypes>(parameters)...));
385
429
}
386
430
387
431
private:
0 commit comments