示例#1
0
        /// <summary>
        /// Send trace message to Baical server or file
        /// See documentation for details.
        /// N.B.: In release mode stack frame information is unavailable, to keep it you need to disable code optimization or disable
        ///       code inlining: [MethodImpl(MethodImplOptions.NoInlining)], but both methods reduces code performance !
        /// </summary>
        public bool Add(UInt16 i_wTraceId,
                        Traces.Level i_eLevel,
                        System.IntPtr i_hModule,
                        Int32 i_dwStackFrame,
                        String i_sMessage
                        )
        {
            StackTrace l_cSt = new StackTrace(true);
            StackFrame l_cSf = l_cSt.GetFrame(i_dwStackFrame);

            System.UInt32 l_dwReturn    = 0;
            int           l_iLineNumber = 0;
            string        l_sMethodName = null;
            string        l_sFileName   = null;

            if (null != l_cSf)
            {
                System.Reflection.MethodBase l_cMethod = l_cSf.GetMethod();

                if (null != l_cMethod)
                {
                    l_sMethodName = l_cMethod.Name;
                }

                l_sFileName   = l_cSf.GetFileName();
                l_iLineNumber = l_cSf.GetFileLineNumber();
            }

            l_dwReturn = P7_Trace_Managed(m_hHandle,
                                          i_wTraceId,
                                          (UInt32)i_eLevel,
                                          i_hModule,
                                          (UInt16)l_iLineNumber,
                                          (null != l_sFileName) ? l_sFileName : "<optimized>",
                                          (null != l_sMethodName) ? l_sMethodName : "<optimized>",
                                          i_sMessage
                                          );

            l_cSf = null;
            l_cSt = null;

            return((0 != l_dwReturn) ? true : false);
        }
示例#2
0
 /// <summary>
 /// Set minimal trace verbosity, all traces with less priority will be
 /// rejected by trace instance. You may set verbosity online from Baical
 /// server
 /// See documentation for details.
 /// </summary>
 public void Set_Verbosity(System.IntPtr i_hModule, Traces.Level i_eLevel)
 {
     P7_Trace_Set_Verbosity(m_hHandle, i_hModule, (UInt32)i_eLevel);
 }