<commit_before>// Copyright (c) 2012-2013, the scalloc Project Authors.  All rights reserved.
// Please see the AUTHORS file for details.  Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.

#ifndef SCALLOC_LOG_H_
#define SCALLOC_LOG_H_

#include <stdarg.h>
#include <unistd.h>

enum Severity {
  kTrace = -1,
  kInfo = -2,
  kWarning = -3,
  kError = -4,
  kFatal = -5
};

const int kVerbosity = kInfo;
const int kLogLen = 240;

void LogPrintf(const int severity, const char* format, ...);

// Here comes the ugly part. What we basically want is a construct that is only
// compiled if the log level is succiciently high. Furthermore we don't even
// want a function call if the severity is too low.
//
// To do so we basically use a varadic macro (with gcc extension to allow empty
// variable args) and create a branch (if with constant expression that is
// false) that _should_ be optimized out by the compiler.

#define LOG_ON(severity) (kVerbosity >= severity)

#define LOG(severity, format, ...) do {           \
  if (LOG_ON(severity)) {                         \
    LogPrintf(severity, format, ##__VA_ARGS__);   \
  }                                               \
  if (severity == FATAL) {                        \<commit_msg>Fixed bug in logger.<commit_after>// Copyright (c) 2012-2013, the scalloc Project Authors.  All rights reserved.
// Please see the AUTHORS file for details.  Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.

#ifndef SCALLOC_LOG_H_
#define SCALLOC_LOG_H_

#include <stdarg.h>
#include <unistd.h>

enum Severity {
  kTrace = -1,
  kInfo = -2,
  kWarning = -3,
  kError = -4,
  kFatal = -5
};

const int kVerbosity = kInfo;
const int kLogLen = 240;

void LogPrintf(const int severity, const char* format, ...);

// Here comes the ugly part. What we basically want is a construct that is only
// compiled if the log level is succiciently high. Furthermore we don't even
// want a function call if the severity is too low.
//
// To do so we basically use a varadic macro (with gcc extension to allow empty
// variable args) and create a branch (if with constant expression that is
// false) that _should_ be optimized out by the compiler.

#define LOG_ON(severity) (kVerbosity >= severity)

#define LOG(severity, format, ...) do {           \
  if (LOG_ON(severity)) {                         \
    LogPrintf(severity, format, ##__VA_ARGS__);   \
  }                                               \
  if (severity == kFatal) {                       \
{'fraction_non_alphanumeric': 0.09281553398058252, 'fraction_numerical': 0.012427184466019418, 'mean_word_length': 2.4346666666666668, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3765460', 'n_tokens_mistral': 806, 'n_tokens_neox': 756, 'n_words': 325}