<commit_before>/******************************************************************
 *
 * uEcho for C
 *
 * Copyright (C) <NAME> 2015
 *
 * This is licensed under BSD-style license, see file COPYING.
 *
 ******************************************************************/

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include <uecho/util/_log.h>
#include <uecho/util/mutex.h>

#if defined(WIN32)
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#endif

static uEchoLogLevel log_level = UECHO_LOG_NONE;
static const char* log_error_s = UECHO_LOG_ERROR_S;
static const char* log_warning_s = UECHO_LOG_WARN_S;
static const char* log_info_s = UECHO_LOG_INFO_S;
static const char* log_debug_s = UECHO_LOG_DEBUG_S;

static const char* uecho_log_type2string(int type)
{
  switch (type) {
  case UECHO_LOG_ERROR:
    return log_error_s;
    break;

  case UECHO_LOG_WARN:
    return log_warning_s;
    break;

  case UECHO_LOG_INFO:
    return log_info_s;
    break;

  case UECHO_LOG_DEBUG:
    return log_debug_s;
    break;
  }

  return "";
}

void uecho_log_setlevel(uEchoLogLevel level)
{
  log_level = level;
}

void uecho_log_output(int severity, const char* file, int line_n, const char* function, const char* format, ...)
{
  va_list list;

  char msg[MAX_LOG_BUF], ts_prefix[MAX_LOG_BUF];
  time_t ts;
  struct tm* localts;
  size_t prefix_len = -1;

  if (log_level < severity)
    return;

  ts = time(NULL);
  localts = localtime(&ts);

  strftime(ts_prefix, MAX_LOG_BUF, "%c", localts);

  prefix_len = snprintf(msg, MAX_LOG_BUF, "%s : %s ", ts_prefix, uecho_log_type2string(severity));

  va_start(list, format);
  vsnprintf(msg + prefix_len, MAX_LOG_BUF - prefix_len, format, list);
  va_end(list);

  printf("%s\n", msg);
}<commit_msg>Update echo_log_output() to output by ISO 8601 format<commit_after>/******************************************************************
 *
 * uEcho for C
 *
 * Copyright (C) <NAME> 2015
 *
 * This is licensed under BSD-style license, see file COPYING.
 *
 ******************************************************************/

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include <uecho/util/_log.h>
#include <uecho/util/mutex.h>

#if defined(WIN32)
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#endif

static uEchoLogLevel log_level = UECHO_LOG_NONE;
static const char* log_error_s = UECHO_LOG_ERROR_S;
static const char* log_warning_s = UECHO_LOG_WARN_S;
static const char* log_info_s = UECHO_LOG_INFO_S;
static const char* log_debug_s = UECHO_LOG_DEBUG_S;

static const char* uecho_log_type2string(int type)
{
  switch (type) {
  case UECHO_LOG_ERROR:
    return log_error_s;
    break;

  case UECHO_LOG_WARN:
    return log_warning_s;
    break;

  case UECHO_LOG_INFO:
    return log_info_s;
    break;

  case UECHO_LOG_DEBUG:
    return log_debug_s;
    break;
  }

  return "";
}

void uecho_log_setlevel(uEchoLogLevel level)
{
  log_level = level;
}

void uecho_log_output(int severity, const char* file, int line_n, const char* function, const char* format, ...)
{
  va_list list;

  char msg[MAX_LOG_BUF], ts_prefix[MAX_LOG_BUF];
  time_t ts;
  struct tm* localts;
  size_t prefix_len = -1;

  if (log_level < severity)
    return;

  ts = time(NULL);
  localts = localtime(&ts);

  strftime(ts_prefix, MAX_LOG_BUF, "%F %T", localts);

  prefix_len = snprintf(msg, MAX_LOG_BUF, "%s : %s ", ts_prefix, uecho_log_type2string(severity));

  va_start(list, format);
  vsnprintf(msg + prefix_len, MAX_LOG_BUF - prefix_len, format, list);
  va_end(list);

  printf("%s\n", msg);
}
{'fraction_non_alphanumeric': 0.17656720503695592, 'fraction_numerical': 0.006022447303586094, 'mean_word_length': 4.754330708661417, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4292806', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1326, 'n_words': 316}