Exemplo n.º 1
0
Arquivo: utils.c Projeto: MUME/mudlle
static void vlog_message(const char *fname, const char *nname, int line,
                         bool is_warning, const char *msg, va_list va)
{
  strbuf_t sb = SBNULL;

  if (fname != NULL)
    {
      bool use_fname = !use_nicename || nname == NULL;

      sb_printf(&sb, "%s:", use_fname ? fname : nname);
      if (line > 0)
        sb_printf(&sb, "%d:", line);
      sb_addc(&sb, ' ');
    }
  if (is_warning)
    sb_addstr(&sb, "warning: ");
  if (!use_nicename && fname != NULL && nname != NULL
      && strcmp(nname, fname) != 0)
    sb_printf(&sb, "[%s] ", nname);
  sb_vprintf(&sb, msg, va);
  if (mudout) pflush(mudout);
  pprintf(muderr, "%s\n", sb_str(&sb));
  if (muderr) pflush(muderr);
  sb_free(&sb);
  if (!is_warning)
    erred = true;
}
Exemplo n.º 2
0
void debug( int level, const wchar_t *msg, ... )
{
	va_list va;

	string_buffer_t sb;
	string_buffer_t sb2;

	int errno_old = errno;

	if( level > debug_level )
		return;

	CHECK( msg, );

	sb_init( &sb );
	sb_init( &sb2 );

	sb_printf( &sb, L"%ls: ", program_name );

	va_start( va, msg );
	sb_vprintf( &sb, msg, va );
	va_end( va );

	write_screen( (wchar_t *)sb.buff, &sb2 );
	fwprintf( stderr, L"%ls", sb2.buff );

	sb_destroy( &sb );
	sb_destroy( &sb2 );

	errno = errno_old;
}