log.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. #pragma once
  2. #include <chrono>
  3. #include <cstring>
  4. #include <sstream>
  5. #include <iostream>
  6. #include <thread>
  7. #include <vector>
  8. #include <algorithm>
  9. #include <cinttypes>
  10. // --------------------------------
  11. //
  12. // Basic usage:
  13. //
  14. // --------
  15. //
  16. // The LOG() and LOG_TEE() macros are ready to go by default
  17. // they do not require any initialization.
  18. //
  19. // LOGLN() and LOG_TEELN() are variants which automatically
  20. // include \n character at the end of the log string.
  21. //
  22. // LOG() behaves exactly like printf, by default writing to a logfile.
  23. // LOG_TEE() additionally, prints to the screen too ( mimics Unix tee command ).
  24. //
  25. // Default logfile is named
  26. // "llama.<threadID>.log"
  27. // Default LOG_TEE() secondary output target is
  28. // stderr
  29. //
  30. // Logs can be dynamically disabled or enabled using functions:
  31. // log_disable()
  32. // and
  33. // log_enable()
  34. //
  35. // A log target can be changed with:
  36. // log_set_target( string )
  37. // creating and opening, or re-opening a file by string filename
  38. // or
  39. // log_set_target( FILE* )
  40. // allowing to point at stderr, stdout, or any valid FILE* file handler.
  41. //
  42. // --------
  43. //
  44. // End of Basic usage.
  45. //
  46. // --------------------------------
  47. // Specifies a log target.
  48. // default uses log_handler() with "llama.log" log file
  49. // this can be changed, by defining LOG_TARGET
  50. // like so:
  51. //
  52. // #define LOG_TARGET (a valid FILE*)
  53. // #include "log.h"
  54. //
  55. // or it can be simply redirected to stdout or stderr
  56. // like so:
  57. //
  58. // #define LOG_TARGET stderr
  59. // #include "log.h"
  60. //
  61. // The log target can also be redirected to a diffrent function
  62. // like so:
  63. //
  64. // #define LOG_TARGET log_handler_diffrent()
  65. // #include "log.h"
  66. //
  67. // FILE* log_handler_diffrent()
  68. // {
  69. // return stderr;
  70. // }
  71. //
  72. // or:
  73. //
  74. // #define LOG_TARGET log_handler_another_one("somelog.log")
  75. // #include "log.h"
  76. //
  77. // FILE* log_handler_another_one(char*filename)
  78. // {
  79. // static FILE* logfile = nullptr;
  80. // (...)
  81. // if( !logfile )
  82. // {
  83. // fopen(...)
  84. // }
  85. // (...)
  86. // return logfile
  87. // }
  88. //
  89. #ifndef LOG_TARGET
  90. #define LOG_TARGET log_handler()
  91. #endif
  92. #ifndef LOG_TEE_TARGET
  93. #define LOG_TEE_TARGET stderr
  94. #endif
  95. // Utility to obtain "pid" like unique process id and use it when creating log files.
  96. inline std::string log_get_pid()
  97. {
  98. static std::string pid;
  99. if (pid.empty())
  100. {
  101. // std::this_thread::get_id() is the most portable way of obtaining a "process id"
  102. // it's not the same as "pid" but is unique enough to solve multiple instances
  103. // trying to write to the same log.
  104. std::stringstream ss;
  105. ss << std::this_thread::get_id();
  106. pid = ss.str();
  107. }
  108. return pid;
  109. }
  110. // Utility function for generating log file names with unique id based on thread id.
  111. // invocation with log_filename_generator( "llama", "log" ) creates a string "llama.<number>.log"
  112. // where the number is a runtime id of the current thread.
  113. #define log_filename_generator(log_file_basename, log_file_extension) log_filename_generator_impl(log_file_basename, log_file_extension)
  114. // INTERNAL, DO NOT USE
  115. inline std::string log_filename_generator_impl(const std::string & log_file_basename, const std::string & log_file_extension)
  116. {
  117. std::stringstream buf;
  118. buf << log_file_basename;
  119. buf << ".";
  120. buf << log_get_pid();
  121. buf << ".";
  122. buf << log_file_extension;
  123. return buf.str();
  124. }
  125. #ifndef LOG_DEFAULT_FILE_NAME
  126. #define LOG_DEFAULT_FILE_NAME log_filename_generator("llama", "log")
  127. #endif
  128. // Utility for turning #define values into string literals
  129. // so we can have a define for stderr and
  130. // we can print "stderr" instead of literal stderr, etc.
  131. #define LOG_STRINGIZE1(s) #s
  132. #define LOG_STRINGIZE(s) LOG_STRINGIZE1(s)
  133. #define LOG_TEE_TARGET_STRING LOG_STRINGIZE(LOG_TEE_TARGET)
  134. // Allows disabling timestamps.
  135. // in order to disable, define LOG_NO_TIMESTAMPS
  136. // like so:
  137. //
  138. // #define LOG_NO_TIMESTAMPS
  139. // #include "log.h"
  140. //
  141. #ifndef LOG_NO_TIMESTAMPS
  142. #ifndef _MSC_VER
  143. #define LOG_TIMESTAMP_FMT "[%" PRIu64 "] "
  144. #define LOG_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count()
  145. #else
  146. #define LOG_TIMESTAMP_FMT "[%" PRIu64 "] "
  147. #define LOG_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count()
  148. #endif
  149. #else
  150. #define LOG_TIMESTAMP_FMT "%s"
  151. #define LOG_TIMESTAMP_VAL ,""
  152. #endif
  153. #ifdef LOG_TEE_TIMESTAMPS
  154. #ifndef _MSC_VER
  155. #define LOG_TEE_TIMESTAMP_FMT "[%" PRIu64 "] "
  156. #define LOG_TEE_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count()
  157. #else
  158. #define LOG_TEE_TIMESTAMP_FMT "[%" PRIu64 "] "
  159. #define LOG_TEE_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count()
  160. #endif
  161. #else
  162. #define LOG_TEE_TIMESTAMP_FMT "%s"
  163. #define LOG_TEE_TIMESTAMP_VAL ,""
  164. #endif
  165. // Allows disabling file/line/function prefix
  166. // in order to disable, define LOG_NO_FILE_LINE_FUNCTION
  167. // like so:
  168. //
  169. // #define LOG_NO_FILE_LINE_FUNCTION
  170. // #include "log.h"
  171. //
  172. #ifndef LOG_NO_FILE_LINE_FUNCTION
  173. #ifndef _MSC_VER
  174. #define LOG_FLF_FMT "[%24s:%5d][%24s] "
  175. #define LOG_FLF_VAL , __FILE__, __LINE__, __FUNCTION__
  176. #else
  177. #define LOG_FLF_FMT "[%24s:%5ld][%24s] "
  178. #define LOG_FLF_VAL , __FILE__, __LINE__, __FUNCTION__
  179. #endif
  180. #else
  181. #define LOG_FLF_FMT "%s"
  182. #define LOG_FLF_VAL ,""
  183. #endif
  184. #ifdef LOG_TEE_FILE_LINE_FUNCTION
  185. #ifndef _MSC_VER
  186. #define LOG_TEE_FLF_FMT "[%24s:%5d][%24s] "
  187. #define LOG_TEE_FLF_VAL , __FILE__, __LINE__, __FUNCTION__
  188. #else
  189. #define LOG_TEE_FLF_FMT "[%24s:%5ld][%24s] "
  190. #define LOG_TEE_FLF_VAL , __FILE__, __LINE__, __FUNCTION__
  191. #endif
  192. #else
  193. #define LOG_TEE_FLF_FMT "%s"
  194. #define LOG_TEE_FLF_VAL ,""
  195. #endif
  196. // Utility for synchronizing log configuration state
  197. // since std::optional was introduced only in c++17
  198. enum LogTriState
  199. {
  200. LogTriStateSame,
  201. LogTriStateFalse,
  202. LogTriStateTrue
  203. };
  204. // INTERNAL, DO NOT USE
  205. // USE LOG() INSTEAD
  206. //
  207. #ifndef _MSC_VER
  208. #define LOG_IMPL(str, ...) \
  209. do { \
  210. if (LOG_TARGET != nullptr) \
  211. { \
  212. fprintf(LOG_TARGET, LOG_TIMESTAMP_FMT LOG_FLF_FMT str "%s" LOG_TIMESTAMP_VAL LOG_FLF_VAL, __VA_ARGS__); \
  213. fflush(LOG_TARGET); \
  214. } \
  215. } while (0)
  216. #else
  217. #define LOG_IMPL(str, ...) \
  218. do { \
  219. if (LOG_TARGET != nullptr) \
  220. { \
  221. fprintf(LOG_TARGET, LOG_TIMESTAMP_FMT LOG_FLF_FMT str "%s" LOG_TIMESTAMP_VAL LOG_FLF_VAL "", ##__VA_ARGS__); \
  222. fflush(LOG_TARGET); \
  223. } \
  224. } while (0)
  225. #endif
  226. // INTERNAL, DO NOT USE
  227. // USE LOG_TEE() INSTEAD
  228. //
  229. #ifndef _MSC_VER
  230. #define LOG_TEE_IMPL(str, ...) \
  231. do { \
  232. if (LOG_TARGET != nullptr) \
  233. { \
  234. fprintf(LOG_TARGET, LOG_TIMESTAMP_FMT LOG_FLF_FMT str "%s" LOG_TIMESTAMP_VAL LOG_FLF_VAL, __VA_ARGS__); \
  235. fflush(LOG_TARGET); \
  236. } \
  237. if (LOG_TARGET != nullptr && LOG_TARGET != stdout && LOG_TARGET != stderr && LOG_TEE_TARGET != nullptr) \
  238. { \
  239. fprintf(LOG_TEE_TARGET, LOG_TEE_TIMESTAMP_FMT LOG_TEE_FLF_FMT str "%s" LOG_TEE_TIMESTAMP_VAL LOG_TEE_FLF_VAL, __VA_ARGS__); \
  240. fflush(LOG_TEE_TARGET); \
  241. } \
  242. } while (0)
  243. #else
  244. #define LOG_TEE_IMPL(str, ...) \
  245. do { \
  246. if (LOG_TARGET != nullptr) \
  247. { \
  248. fprintf(LOG_TARGET, LOG_TIMESTAMP_FMT LOG_FLF_FMT str "%s" LOG_TIMESTAMP_VAL LOG_FLF_VAL "", ##__VA_ARGS__); \
  249. fflush(LOG_TARGET); \
  250. } \
  251. if (LOG_TARGET != nullptr && LOG_TARGET != stdout && LOG_TARGET != stderr && LOG_TEE_TARGET != nullptr) \
  252. { \
  253. fprintf(LOG_TEE_TARGET, LOG_TEE_TIMESTAMP_FMT LOG_TEE_FLF_FMT str "%s" LOG_TEE_TIMESTAMP_VAL LOG_TEE_FLF_VAL "", ##__VA_ARGS__); \
  254. fflush(LOG_TEE_TARGET); \
  255. } \
  256. } while (0)
  257. #endif
  258. // The '\0' as a last argument, is a trick to bypass the silly
  259. // "warning: ISO C++11 requires at least one argument for the "..." in a variadic macro"
  260. // so we can have a single macro which can be called just like printf.
  261. // Main LOG macro.
  262. // behaves like printf, and supports arguments the exact same way.
  263. //
  264. #ifndef _MSC_VER
  265. #define LOG(...) LOG_IMPL(__VA_ARGS__, "")
  266. #else
  267. #define LOG(str, ...) LOG_IMPL("%s" str, "", __VA_ARGS__, "")
  268. #endif
  269. // Main TEE macro.
  270. // does the same as LOG
  271. // and
  272. // simultaneously writes stderr.
  273. //
  274. // Secondary target can be changed just like LOG_TARGET
  275. // by defining LOG_TEE_TARGET
  276. //
  277. #ifndef _MSC_VER
  278. #define LOG_TEE(...) LOG_TEE_IMPL(__VA_ARGS__, "")
  279. #else
  280. #define LOG_TEE(str, ...) LOG_TEE_IMPL("%s" str, "", __VA_ARGS__, "")
  281. #endif
  282. // LOG macro variants with auto endline.
  283. #ifndef _MSC_VER
  284. #define LOGLN(...) LOG_IMPL(__VA_ARGS__, "\n")
  285. #define LOG_TEELN(...) LOG_TEE_IMPL(__VA_ARGS__, "\n")
  286. #else
  287. #define LOGLN(str, ...) LOG_IMPL("%s" str, "", __VA_ARGS__, "\n")
  288. #define LOG_TEELN(str, ...) LOG_TEE_IMPL("%s" str, "", __VA_ARGS__, "\n")
  289. #endif
  290. // INTERNAL, DO NOT USE
  291. inline FILE *log_handler1_impl(bool change = false, LogTriState disable = LogTriStateSame, const std::string & filename = LOG_DEFAULT_FILE_NAME, FILE *target = nullptr)
  292. {
  293. static bool _initialized{false};
  294. static bool _disabled{(filename.empty() && target == nullptr)};
  295. static std::string log_current_filename{filename};
  296. static FILE *log_current_target{target};
  297. static FILE *logfile = nullptr;
  298. if (change)
  299. {
  300. if (disable == LogTriStateTrue)
  301. {
  302. // Disable primary target
  303. _disabled = true;
  304. }
  305. // If previously disabled, only enable, and keep previous target
  306. else if (disable == LogTriStateFalse)
  307. {
  308. _disabled = false;
  309. }
  310. // Otherwise, process the arguments
  311. else if (log_current_filename != filename || log_current_target != target)
  312. {
  313. _initialized = false;
  314. }
  315. }
  316. if (_disabled)
  317. {
  318. // Log is disabled
  319. return nullptr;
  320. }
  321. if (_initialized)
  322. {
  323. // with fallback in case something went wrong
  324. return logfile ? logfile : stderr;
  325. }
  326. // do the (re)initialization
  327. if (target != nullptr)
  328. {
  329. if (logfile != nullptr && logfile != stdout && logfile != stderr)
  330. {
  331. fclose(logfile);
  332. }
  333. log_current_filename = LOG_DEFAULT_FILE_NAME;
  334. log_current_target = target;
  335. logfile = target;
  336. }
  337. else
  338. {
  339. if (log_current_filename != filename)
  340. {
  341. if (logfile != nullptr && logfile != stdout && logfile != stderr)
  342. {
  343. fclose(logfile);
  344. }
  345. }
  346. logfile = fopen(filename.c_str(), "w");
  347. }
  348. if (!logfile)
  349. {
  350. // Verify whether the file was opened, otherwise fallback to stderr
  351. logfile = stderr;
  352. fprintf(stderr, "Failed to open logfile '%s' with error '%s'\n", filename.c_str(), std::strerror(errno));
  353. fflush(stderr);
  354. // At this point we let the init flag be to true below, and let the target fallback to stderr
  355. // otherwise we would repeatedly fopen() which was already unsuccessful
  356. }
  357. _initialized = true;
  358. return logfile ? logfile : stderr;
  359. }
  360. // INTERNAL, DO NOT USE
  361. inline FILE *log_handler2_impl(bool change = false, LogTriState disable = LogTriStateSame, FILE *target = nullptr, const std::string & filename = LOG_DEFAULT_FILE_NAME)
  362. {
  363. return log_handler1_impl(change, disable, filename, target);
  364. }
  365. // Disables logs entirely at runtime.
  366. // Makes LOG() and LOG_TEE() produce no output,
  367. // untill enabled back.
  368. #define log_disable() log_disable_impl()
  369. // INTERNAL, DO NOT USE
  370. inline FILE *log_disable_impl()
  371. {
  372. return log_handler1_impl(true, LogTriStateTrue);
  373. }
  374. // Enables logs at runtime.
  375. #define log_enable() log_enable_impl()
  376. // INTERNAL, DO NOT USE
  377. inline FILE *log_enable_impl()
  378. {
  379. return log_handler1_impl(true, LogTriStateFalse);
  380. }
  381. // Sets target fir logs, either by a file name or FILE* pointer (stdout, stderr, or any valid FILE*)
  382. #define log_set_target(target) log_set_target_impl(target)
  383. // INTERNAL, DO NOT USE
  384. inline FILE *log_set_target_impl(const std::string & filename) { return log_handler1_impl(true, LogTriStateSame, filename); }
  385. inline FILE *log_set_target_impl(FILE *target) { return log_handler2_impl(true, LogTriStateSame, target); }
  386. // INTERNAL, DO NOT USE
  387. inline FILE *log_handler() { return log_handler1_impl(); }
  388. inline void log_test()
  389. {
  390. log_disable();
  391. LOG("01 Hello World to nobody, because logs are disabled!\n");
  392. log_enable();
  393. LOG("02 Hello World to default output, which is \"%s\" ( Yaaay, arguments! )!\n", LOG_STRINGIZE(LOG_TARGET));
  394. LOG_TEE("03 Hello World to **both** default output and " LOG_TEE_TARGET_STRING "!\n");
  395. log_set_target(stderr);
  396. LOG("04 Hello World to stderr!\n");
  397. LOG_TEE("05 Hello World TEE with double printing to stderr prevented!\n");
  398. log_set_target(LOG_DEFAULT_FILE_NAME);
  399. LOG("06 Hello World to default log file!\n");
  400. log_set_target(stdout);
  401. LOG("07 Hello World to stdout!\n");
  402. log_set_target(LOG_DEFAULT_FILE_NAME);
  403. LOG("08 Hello World to default log file again!\n");
  404. log_disable();
  405. LOG("09 Hello World _1_ into the void!\n");
  406. log_enable();
  407. LOG("10 Hello World back from the void ( you should not see _1_ in the log or the output )!\n");
  408. log_disable();
  409. log_set_target("llama.anotherlog.log");
  410. LOG("11 Hello World _2_ to nobody, new target was selected but logs are still disabled!\n");
  411. log_enable();
  412. LOG("12 Hello World this time in a new file ( you should not see _2_ in the log or the output )?\n");
  413. log_set_target("llama.yetanotherlog.log");
  414. LOG("13 Hello World this time in yet new file?\n");
  415. log_set_target(log_filename_generator("llama_autonamed", "log"));
  416. LOG("14 Hello World in log with generated filename!\n");
  417. #ifdef _MSC_VER
  418. LOG_TEE("15 Hello msvc TEE without arguments\n");
  419. LOG_TEE("16 Hello msvc TEE with (%d)(%s) arguments\n", 1, "test");
  420. LOG_TEELN("17 Hello msvc TEELN without arguments\n");
  421. LOG_TEELN("18 Hello msvc TEELN with (%d)(%s) arguments\n", 1, "test");
  422. LOG("19 Hello msvc LOG without arguments\n");
  423. LOG("20 Hello msvc LOG with (%d)(%s) arguments\n", 1, "test");
  424. LOGLN("21 Hello msvc LOGLN without arguments\n");
  425. LOGLN("22 Hello msvc LOGLN with (%d)(%s) arguments\n", 1, "test");
  426. #endif
  427. }
  428. inline bool log_param_single_parse(const std::string & param)
  429. {
  430. if ( param == "--log-test")
  431. {
  432. log_test();
  433. return true;
  434. }
  435. if ( param == "--log-disable")
  436. {
  437. log_disable();
  438. return true;
  439. }
  440. if ( param == "--log-enable")
  441. {
  442. log_enable();
  443. return true;
  444. }
  445. return false;
  446. }
  447. inline bool log_param_pair_parse(bool check_but_dont_parse, const std::string & param, const std::string & next = std::string())
  448. {
  449. if ( param == "--log-file")
  450. {
  451. if (!check_but_dont_parse)
  452. {
  453. log_set_target(log_filename_generator(next.empty() ? "unnamed" : next, "log"));
  454. }
  455. return true;
  456. }
  457. return false;
  458. }
  459. inline void log_print_usage()
  460. {
  461. printf("log options:\n");
  462. /* format
  463. printf(" -h, --help show this help message and exit\n");*/
  464. /* spacing
  465. printf("__-param----------------Description\n");*/
  466. printf(" --log-test Run simple logging test\n");
  467. printf(" --log-disable Disable trace logs\n");
  468. printf(" --log-enable Enable trace logs\n");
  469. printf(" --log-file Specify a log filename (without extension)\n");
  470. printf(" Log file will be tagged with unique ID and written as \"<name>.<ID>.log\"\n"); /* */
  471. }
  472. #define log_dump_cmdline(argc, argv) log_dump_cmdline_impl(argc, argv)
  473. // INTERNAL, DO NOT USE
  474. inline void log_dump_cmdline_impl(int argc, char **argv)
  475. {
  476. std::stringstream buf;
  477. for (int i = 0; i < argc; ++i)
  478. {
  479. if (std::string(argv[i]).find(' ') != std::string::npos)
  480. {
  481. buf << " \"" << argv[i] <<"\"";
  482. }
  483. else
  484. {
  485. buf << " " << argv[i];
  486. }
  487. }
  488. LOGLN("Cmd:%s", buf.str().c_str());
  489. }
  490. #define log_tostr(var) log_var_to_string_impl(var).c_str()
  491. inline std::string log_var_to_string_impl(bool var)
  492. {
  493. return var ? "true" : "false";
  494. }
  495. inline std::string log_var_to_string_impl(std::string var)
  496. {
  497. return var;
  498. }
  499. inline std::string log_var_to_string_impl(const std::vector<int> & var)
  500. {
  501. std::stringstream buf;
  502. buf << "[ ";
  503. bool first = true;
  504. for (auto e : var)
  505. {
  506. if (first)
  507. {
  508. first = false;
  509. }
  510. else
  511. {
  512. buf << ", ";
  513. }
  514. buf << std::to_string(e);
  515. }
  516. buf << " ]";
  517. return buf.str();
  518. }
  519. #define LOG_TOKENS_TOSTR_PRETTY(ctx, tokens) \
  520. [&tokens, &ctx]() \
  521. { \
  522. std::stringstream buf; \
  523. buf << "[ "; \
  524. \
  525. bool first = true; \
  526. for (const auto &token : tokens) \
  527. { \
  528. if (!first) \
  529. buf << ", "; \
  530. else \
  531. first = false; \
  532. \
  533. auto detokenized = llama_token_to_piece(ctx, token); \
  534. \
  535. detokenized.erase( \
  536. std::remove_if( \
  537. detokenized.begin(), \
  538. detokenized.end(), \
  539. [](const unsigned char c) { return !std::isprint(c); }), \
  540. detokenized.end()); \
  541. \
  542. buf \
  543. << "'" << detokenized << "'" \
  544. << ":" << std::to_string(token); \
  545. } \
  546. buf << " ]"; \
  547. \
  548. return buf.str(); \
  549. }() \
  550. .c_str()
  551. #ifdef LOG_DISABLE_LOGS
  552. #undef LOG
  553. #define LOG(...) // dummy stub
  554. #undef LOGLN
  555. #define LOGLN(...) // dummy stub
  556. #undef LOG_TEE
  557. #define LOG_TEE(...) fprintf(stderr, __VA_ARGS__) // convert to normal fprintf
  558. #undef LOG_TEELN
  559. #define LOG_TEELN(...) fprintf(stderr, __VA_ARGS__) // convert to normal fprintf
  560. #undef LOG_DISABLE
  561. #define LOG_DISABLE() // dummy stub
  562. #undef LOG_ENABLE
  563. #define LOG_ENABLE() // dummy stub
  564. #undef LOG_ENABLE
  565. #define LOG_ENABLE() // dummy stub
  566. #undef LOG_SET_TARGET
  567. #define LOG_SET_TARGET(...) // dummy stub
  568. #undef LOG_DUMP_CMDLINE
  569. #define LOG_DUMP_CMDLINE(...) // dummy stub
  570. #endif // LOG_DISABLE_LOGS