kakoune/src/debug.cc

29 lines
568 B
C++
Raw Normal View History

#include "debug.hh"
#include "assert.hh"
#include "buffer.hh"
#include "buffer_manager.hh"
namespace Kakoune
{
void write_debug(const String& str)
{
if (not BufferManager::has_instance())
{
fprintf(stderr, "%s\n", str.c_str());
return;
}
static const String debug_buffer_name("*debug*");
Buffer* buffer = BufferManager::instance().get_buffer_ifp(debug_buffer_name);
if (not buffer)
buffer = new Buffer(debug_buffer_name, Buffer::Flags::NoUndo);
kak_assert(buffer);
buffer->insert(buffer->end(), str);
}
}