Make it possible to set log file

And use stdout for CC3200 demo because
  (1) an apparent bug which causes output sent to stderr to be
      printed v-e-r-y s-l-o-w-l-y (yes, it is really like that;
      https://e2e.ti.com/support/development_tools/code_composer_studio/f/81/t/501881)
  (2) in CCS it is printed in BLOOD RED, which is annoying

PUBLISHED_FROM=36a86744bc8ea193e99e98670dadc7f3ab6ed53e
This commit is contained in:
Deomid Ryabkov authored and rojer committed 2016-04-01 03:14:29 +01:00
1 parent c9fc7a1320
commit fb53cd37e7
3 files changed
+32 -20

No files matched your search

+19 -8
View File
@@ -346,41 +346,52 @@ int cs_base64_decode(const unsigned char *s, int len, char *dst) {
/* Amalgamated: #include "common/cs_time.h" */
enum cs_log_level s_cs_log_level =
enum cs_log_level cs_log_level =
#ifdef CS_ENABLE_DEBUG
LL_VERBOSE_DEBUG;
#else
LL_ERROR;
#endif
#ifndef CS_DISABLE_STDIO
FILE *cs_log_file = NULL;
#ifdef CS_LOG_TS_DIFF
double cs_log_ts;
#endif
#ifndef CS_DISABLE_STDIO
void cs_log_printf(const char *fmt, ...) {
va_list ap;
#ifdef CS_LOG_TS_DIFF
double now = cs_time();
fprintf(stderr, "%7u ", (unsigned int) ((now - cs_log_ts) * 1000000));
#endif
if (cs_log_file == NULL) cs_log_file = stderr;
#ifdef CS_LOG_TS_DIFF
fprintf(cs_log_file, "%7u ", (unsigned int) ((now - cs_log_ts) * 1000000));
#endif
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
vfprintf(cs_log_file, fmt, ap);
va_end(ap);
fputc('\n', stderr);
fputc('\n', cs_log_file);
#ifdef CS_LOG_TS_DIFF
cs_log_ts = now;
#endif
fflush(stderr);
fflush(cs_log_file);
}
#endif /* !CS_DISABLE_STDIO */
void cs_log_set_level(enum cs_log_level level) {
s_cs_log_level = level;
#ifdef CS_LOG_TS_DIFF
cs_log_level = level;
#if defined(CS_LOG_TS_DIFF) && !defined(CS_DISABLE_STDIO)
cs_log_ts = cs_time();
#endif
}
void cs_log_set_file(FILE *file) {
cs_log_file = file;
}
#ifdef MG_MODULE_LINES
#line 1 "./src/../../common/cs_dirent.c"
#endif