<commit_before>// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2004-2006 <NAME> <<EMAIL>>
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software
 * Foundation.  See file COPYING.
 *
 */

#ifndef CEPH_DEBUG_H
#define CEPH_DEBUG_H

#include "common/likely.h"
#include "include/assert.h"
#include "Mutex.h"
#include "Clock.h"

#include <iosfwd>
using std::ostream;

// the streams
extern ostream *_dout;

extern Mutex _dout_lock;

extern bool _dout_need_open;
extern bool _dout_is_open;

extern void _dout_open_log();

extern int dout_rename_output_file();  // after calling daemon()
extern int dout_create_rank_symlink(int64_t n);

static inline void _dout_check_log() {
  _dout_lock.Lock();
  if (unlikely(_dout_need_open))
    _dout_open_log();
  _dout_lock.Unlock();
}

static inline void _dout_begin_line(int prio) {
  _dout_lock.Lock();
  if (unlikely(_dout_need_open))
    _dout_open_log();
  *_dout << g_clock.now() << " " << std::hex << pthread_self() << std::dec << " ";
}
static inline void _dout_end_line() {
  _dout_lock.Unlock();
}

// intentionally conflict with endl
class _bad_endl_use_dendl_t { public: _bad_endl_use_dendl_t(int) {} };
static const _bad_endl_use_dendl_t endl = 0;
inline ostream& operator<<(ostream& out, _bad_endl_use_dendl_t) {
  assert(0 && "you are using the wrong endl.. use std::endl or dendl");
  return out;
}


// generic macros
#define generic_dout(x) do { if ((x) <= g_conf.debug) {\
  _dout_begin_line(x); *_dout

#define pdout(x,p) do { if ((x) <= (p)) {\
  _dout_begin_line(x); *_dout

#define debug_DOUT_SUBSYS debug
#define dout_prefix *_dout
#define DOUT_CONDVAR(x) g_conf.debug_ ## x
#define XDOUT_CONDVAR(x) DOUT_CONDVAR(x)
#define DOUT_COND(l) l <= XDOUT_CONDVAR(DOUT_SUBSYS)

#define dout(l) do { if (DOUT_COND(l)) {\
  _dout_begin_line(l); dout_prefix

#define dendl std::endl; _dout_end_line(); } } while (0)


extern void hex2str(const char *s, int len, char *buf, int dest_len);

extern void hexdump(string msg, const char *s, int len);

#endif
<commit_msg>logging: debug.h: minor cleanup<commit_after>// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2004-2010 <NAME> <<EMAIL>>
 * Copyright (C) 2010 Dreamhost
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software
 * Foundation.  See file COPYING.
 *
 */

#ifndef CEPH_DEBUG_H
#define CEPH_DEBUG_H

#include "common/likely.h"
#include "include/assert.h"
#include "Mutex.h"
#include "Clock.h"

#include <iosfwd>

// the streams
extern std::ostream *_dout;

extern Mutex _dout_lock;

extern bool _dout_need_open;
extern bool _dout_is_open;

extern void _dout_open_log();

extern int dout_rename_output_file();  // after calling daemon()
extern int dout_create_rank_symlink(int64_t n);

static inline void _dout_check_log() {
  _dout_lock.Lock();
  if (unlikely(_dout_need_open))
    _dout_open_log();
  _dout_lock.Unlock();
}

static inline void _dout_begin_line(int prio) {
  _dout_lock.Lock();
  if (unlikely(_dout_need_open))
    _dout_open_log();
  *_dout << g_clock.now() << " " << std::hex << pthread_self() << std::dec << " ";
}
static inline void _dout_end_line() {
  _dout_lock.Unlock();
}

// intentionally conflict with endl
class _bad_endl_use_dendl_t { public: _bad_endl_use_dendl_t(int) {} };
static const _bad_endl_use_dendl_t endl = 0;
inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) {
  assert(0 && "you are using the wrong endl.. use std::endl or dendl");
  return out;
}

// generic macros
#define generic_dout(x) do { if ((x) <= g_conf.debug) {\
  _dout_begin_line(x); *_dout

#define pdout(x,p) do { if ((x) <= (p)) {\
  _dout_begin_line(x); *_dout

#define debug_DOUT_SUBSYS debug
#define dout_prefix *_dout
#define DOUT_CONDVAR(x) g_conf.debug_ ## x
#define XDOUT_CONDVAR(x) DOUT_CONDVAR(x)
#define DOUT_COND(l) l <= XDOUT_CONDVAR(DOUT_SUBSYS)

#define dout(l) do { if (DOUT_COND(l)) {\
  _dout_begin_line(l); dout_prefix

#define dendl std::endl; _dout_end_line(); } } while (0)


extern void hex2str(const char *s, int len, char *buf, int dest_len);

extern void hexdump(string msg, const char *s, int len);

#endif

{'fraction_non_alphanumeric': 0.13592446201141853, 'fraction_numerical': 0.00966183574879227, 'mean_word_length': 4.795165394402035, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 11, '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': '67779', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1760, 'n_words': 451}