trace.cpp

来自「Shorthand是一个强大的脚本语言」· C++ 代码 · 共 49 行

CPP
49
字号
///////////////////////////////////////////////////////////////////////////////
// $Header: /shorthand/src/trace.cpp 3     8/28/02 6:27a Arm $
//-----------------------------------------------------------------------------
// Project: ShortHand interpreter
// Author: Andrei Remenchuk <andrei@remenchuk.com>
//-----------------------------------------------------------------------------
// trace.cpp: ShortHand debug diagnostics
///////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <malloc.h>
#include <string.h>

#include "shorthand.h"
#include "utils.h"

#ifndef WIN32
#include <stdlib.h>
#include <unistd.h>
#endif


#ifdef _DEBUG

static FILE* trace_file = NULL;
int trace_level = 0;

void trace(int level, const char* format, ...)
{
    if (trace_level >= level)
    {
        if (trace_file == NULL) {
            const char* home = get_home_dir();
            char* name = (char*) alloca(strlen(home) + 20);
            sprintf(name, "%sshorthand.trace", home);
            trace_file = fopen(name, "w");
        }
        if (trace_file != NULL)
        {
            va_list args; va_start(args, format);
            vfprintf(trace_file, format, args);
            fflush(trace_file);
        }
    }
}


#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?