summaryrefslogtreecommitdiffstats
path: root/libvideoeditor/osal/src/M4PSW_DebugTrace.c
blob: 850ed91bc8715d101cd62318126685ade9e3b290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 ************************************************************************
 * @file       M4PSW_DebugTrace.c
 * @brief      Default trace function for debugging macros
 * @note       This file gives the default implementation of the trace function
 *             used in the debug instrumentation macros, based on printf.
 *             Application writers are strongly encouraged to implement their
 *             own "M4OSA_DebugTrace".
 ************************************************************************
*/


#include <inttypes.h>
#include <stdio.h> /*for printf */

#include "M4OSA_Types.h"
#include "M4OSA_Error.h"

/*#define NO_FILE */ /* suppresses the file name print out */


/**
 ************************************************************************
 * void M4OSA_DebugTrace(M4OSA_Int32 line, char* file, M4OSA_Int32 level,
 *                       M4OSA_Char* cond, char* msg, M4OSA_ERR err)
 * @brief    This function implements the trace for debug tests
 * @note    This function is to be called in the debug macros only.
 *            This implementation uses printf.
 * @param    line (IN): the line number in the source file
 * @param    file (IN): the source file name
 * @param    level (IN): the debug level
 * @param    msg (IN): the error message
 * @param    err (IN): the return value (error code)
 * @return    none
 ************************************************************************
*/

M4OSAL_TRACE_EXPORT_TYPE void M4OSA_DebugTrace(M4OSA_Int32 line,
                                               M4OSA_Char* file,
                                               M4OSA_Int32 level,
                                               M4OSA_Char* cond,
                                               M4OSA_Char* msg,
                                               M4OSA_ERR err)
{
    M4OSA_Int32 i;

    /* try to "indent" the resulting traces depending on the level */
    for (i =0 ; i < level; i ++)
    {
        printf(" ");
    }

#ifdef NO_FILE
    printf("Error: %" PRIu32 ", on %s: %s\n",err,cond,msg);
#else /* NO_FILE     */
    printf("Error: %" PRIu32 ", on %s: %s Line %" PRIu32 " in: %s\n",err,cond,msg,line,file);
#endif /* NO_FILE     */

}

M4OSAL_TRACE_EXPORT_TYPE M4OSA_Void M4OSA_DEBUG_traceFunction(M4OSA_UInt32 line,
                                                              M4OSA_Char* fileName,
                                                              M4OSA_UInt32 level,
                                                              M4OSA_Char* stringCondition,
                                                              M4OSA_Char* message,
                                                              M4OSA_ERR returnedError)
{
    M4OSA_DebugTrace(line, fileName, level, stringCondition, message, returnedError);
}