int TestFrameworkClient::tf_write(const char *buf)
{
    int ret = 0, status = 0;
    bool send = false;

    status = tf_logging_status();

    switch(status) {
    case TF_LOGCAT:
        __android_log_write(ANDROID_LOG_ERROR, LOG_TAG, buf);
        break;
    case TF_TESTFRAMEWORK:
    case TF_ALL:
        send = true;
        break;
    case TF_DISABLE:
        break;
    }

    if (send) {
#ifdef TF_FEATURE_MSGS_THROUGH_BINDER
        mTfDispacther->DispatchMsg(buf);
#else
        ret = TfWrite(buf);
#endif
    }

    return ret;
}
int TestFrameworkClient::tf_print(int eventtype, const char *eventgrp,
             const char *eventid, const char *fmt, va_list ap) {
    char evarg[TF_LOG_BUF_SIZE];
    int ret = 0, idx=0, status = TF_DISABLE;
    bool send = false;

    status = tf_logging_status();

    if (TF_DISABLE == status ||
        !(mEventType & eventtype) ||
        !TfSearchFilterInTable(eventgrp, eventid) ||
        !IsTraceGatesOpen()) {
        return 0;
    }

    switch(status) {
    case TF_LOGCAT: {
        __android_log_vprint(ANDROID_LOG_ERROR, eventgrp, fmt, ap);
    }
    break;
    case TF_LOGCAT_FTRACE:
    break;
    case TF_TESTFRAMEWORK: {
        char modifiedEventID[TF_EVENT_ID_SIZE_MAX];

        if (!TfIsValid()) {
            TfTracersInit();
        }

        //add pid to eve
        snprintf(modifiedEventID, TF_EVENT_ID_SIZE_MAX, "%s-%d", eventid, getpid());
        snprintf(evarg, TF_LOG_BUF_SIZE, "name=%s [class=%s, info=", modifiedEventID, eventgrp);
        idx = strlen(evarg);
        vsnprintf (evarg+idx, TF_LOG_BUF_SIZE-idx, fmt, ap);
        idx = strlen(evarg);
        snprintf (evarg+idx, TF_LOG_BUF_SIZE-idx, " {%s}", tf_get_str_eventtype(eventtype));
        idx = strlen(evarg);
        if (idx < TF_LOG_BUF_SIZE-2) {
            strlcpy(evarg+idx, "]\n", TF_LOG_BUF_SIZE-idx);
        }
        send = true;
    }
    break;
    case TF_ALL: {
        char modifiedEventID[TF_EVENT_ID_SIZE_MAX];

        if (!TfIsValid()) {
            TfTracersInit();
        }

        //add pid to events
        snprintf(modifiedEventID, TF_EVENT_ID_SIZE_MAX, "%s-%d", eventid, getpid());
        __android_log_vprint(ANDROID_LOG_ERROR, eventgrp, fmt, ap);
        snprintf(evarg, TF_LOG_BUF_SIZE, "name=%s [class=%s, info=", modifiedEventID, eventgrp);
        idx = strlen(evarg);
        vsnprintf (evarg+idx, TF_LOG_BUF_SIZE-idx, fmt, ap);
        idx = strlen(evarg);
        snprintf (evarg+idx, TF_LOG_BUF_SIZE-idx, " {%s}", tf_get_str_eventtype(eventtype));
        idx = strlen(evarg);
        if (idx < TF_LOG_BUF_SIZE-2) {
            strlcpy(evarg+idx, "]\n", TF_LOG_BUF_SIZE-idx);
        }
        send = true;
    }
    break;
    case TF_DISABLE:
    default:
        break;
    }


    if (send) {
#ifdef TF_FEATURE_MSGS_THROUGH_BINDER
        if (mTfDispacther != 0) {
            mTfDispacther->DispatchMsg(eventtype, evarg);
        }
#else
        ret = TfWrite(eventtype, evarg);
#endif
    }

    return ret;
}