home/src/debug.cc

30 lines
598 B
C++
Raw Normal View History

#include "debug.hh"
#include "assert.hh"
#include "buffer.hh"
#include "buffer_manager.hh"
2014-11-12 22:27:07 +01:00
#include "string.hh"
namespace Kakoune
{
2014-04-30 20:27:38 +02:00
void write_debug(StringView str)
{
if (not BufferManager::has_instance())
{
2014-04-30 20:27:38 +02:00
fprintf(stderr, "%s\n", (const char*)str.zstr());
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);
}
}