예제 #1
0
        public static void Log(LibRTMPLogLevel logLevel, string message)
        {
#if !__ANDROID__
            if (activeLogLevel != LibRTMPLogLevel.None && Convert.ToInt32(activeLogLevel) >= Convert.ToInt32(logLevel))
            {
                string line = string.Format("[{0}]: {1}", logLevel, message);
                Console.WriteLine(line);
#if !__IOS__
                if (LogToFile)
                {
                    lock (lockLogFile)
                    {
                        if (!File.Exists(LogFilename))
                        {
                            // Create a file to write to.
                            using (StreamWriter sw = File.CreateText(LogFilename))
                            {
                                sw.WriteLine(line);
                            } //using
                        }
                        else
                        {
                            using (StreamWriter sw = File.AppendText(LogFilename))
                            {
                                sw.WriteLine(line);
                            } //using
                        }
                    }         //lock
                }
#endif
            }
#endif
        }
예제 #2
0
 public void Dump(LibRTMPLogLevel loglevel = LibRTMPLogLevel.Trace)
 {
     for (int n = 0; n < properties.Count; n++)
     {
         properties[n].Dump(loglevel);
     }
 }
예제 #3
0
        public static void Log(LibRTMPLogLevel logLevel, string message)
        {
#if !__ANDROID__
            if (activeLogLevel != LibRTMPLogLevel.None && Convert.ToInt32(activeLogLevel) >= Convert.ToInt32(logLevel))
            {
                string line = string.Format("[{0}]: {1}", logLevel, message);
                Console.WriteLine(line);
#if !__IOS__
                if (LogToFile)
                {
                    lock (lockLogFile)
                    {
                        if (!File.Exists(LogFilename))
                        {
                            // Create a file to write to. 
                            using (StreamWriter sw = File.CreateText(LogFilename))
                            {
                                sw.WriteLine(line);
                            } //using
                        }
                        else
                        {
                            using (StreamWriter sw = File.AppendText(LogFilename))
                            {
                                sw.WriteLine(line);
                            } //using
                        }
                    } //lock
                }
#endif
            }
#endif
        }
예제 #4
0
        public void Dump(LibRTMPLogLevel loglevel = LibRTMPLogLevel.Trace)
        {
            if (type == AMFDataType.AMF_INVALID)
            {
                LibRTMPLogger.Log(loglevel, "AMFObjectProperty.Dump: Property: INVALID");
                return;
            }

            if (type == AMFDataType.AMF_NULL)
            {
                LibRTMPLogger.Log(loglevel, "AMFObjectProperty.Dump: Property: NULL");
                return;
            }

            if (type == AMFDataType.AMF_OBJECT)
            {
                LibRTMPLogger.Log(loglevel, "AMFObjectProperty.Dump : Property: OBJECT ====>");
                objVal.Dump();
                return;
            }

            string strRes = "no-name. ";

            if (stringName != string.Empty)
            {
                strRes = "Name: " + stringName + ",  ";
            }

            string strVal;

            switch (type)
            {
            case AMFDataType.AMF_NUMBER:
                strVal = string.Format("NUMBER: {0}", numVal);
                break;

            case AMFDataType.AMF_BOOLEAN:
                strVal = string.Format("BOOLEAN: {0}", numVal == 1.0 ? "TRUE" : "FALSE");
                break;

            case AMFDataType.AMF_STRING:
                strVal = string.Format("STRING: {0}", stringVal.Length < 256 ? stringVal : "Length: " + stringVal.Length.ToString());
                break;

            default:
                strVal = string.Format("INVALID TYPE {0}", type);
                break;
            } //switch

            strRes += strVal;
            LibRTMPLogger.Log(loglevel, string.Format("Property: {0}", strRes));
        }
예제 #5
0
        public static void LogHex(LibRTMPLogLevel logLevel, byte[] array, int offset, int count)
        {
#if !__IOS__ && !__ANDROID__
            if (activeLogLevel != LibRTMPLogLevel.None && Convert.ToInt32(activeLogLevel) >= Convert.ToInt32(logLevel))
            {
                string result = string.Empty;
                for (int i = offset; i < offset + count; i++)
                {
                    result += array[i].ToString("x2") + " ";
                    if (result.Length >= 47)
                    {
                        Log(logLevel, result.Trim());
                        result = string.Empty;
                    }
                } //for
                if (result.Length > 0)
                {
                    Log(logLevel, result.Trim());
                }
            }
#endif
        }
예제 #6
0
 public void Dump(LibRTMPLogLevel loglevel = LibRTMPLogLevel.Trace)
 {
     for (int n = 0; n < properties.Count; n++)
     {
         properties[n].Dump(loglevel);
     }
 }
        public void Dump(LibRTMPLogLevel loglevel = LibRTMPLogLevel.Trace)
        {
            if (type == AMFDataType.AMF_INVALID)
            {
                LibRTMPLogger.Log(loglevel, "AMFObjectProperty.Dump: Property: INVALID");
                return;
            }

            if (type == AMFDataType.AMF_NULL)
            {
                LibRTMPLogger.Log(loglevel, "AMFObjectProperty.Dump: Property: NULL");
                return;
            }

            if (type == AMFDataType.AMF_OBJECT)
            {
                LibRTMPLogger.Log(loglevel, "AMFObjectProperty.Dump : Property: OBJECT ====>");
                objVal.Dump();
                return;
            }

            string strRes = "no-name. ";
            if (stringName != string.Empty)
            {
                strRes = "Name: " + stringName + ",  ";
            }

            string strVal;

            switch (type)
            {
                case AMFDataType.AMF_NUMBER:
                    strVal = string.Format("NUMBER: {0}", numVal);
                    break;
                case AMFDataType.AMF_BOOLEAN:
                    strVal = string.Format("BOOLEAN: {0}", numVal == 1.0 ? "TRUE" : "FALSE");
                    break;
                case AMFDataType.AMF_STRING:
                    strVal = string.Format("STRING: {0}", stringVal.Length < 256 ? stringVal : "Length: " + stringVal.Length.ToString());
                    break;
                default:
                    strVal = string.Format("INVALID TYPE {0}", type);
                    break;
            } //switch

            strRes += strVal;
            LibRTMPLogger.Log(loglevel, string.Format("Property: {0}", strRes));
        }
예제 #8
0
        public static void LogHex(LibRTMPLogLevel logLevel, byte[] array, int offset, int count)
        {
#if !__IOS__ && !__ANDROID
            if (activeLogLevel != LibRTMPLogLevel.None && Convert.ToInt32(activeLogLevel) >= Convert.ToInt32(logLevel))
            {
                string result = string.Empty;
                for (int i = offset; i < offset + count; i++)
                {
                    result += array[i].ToString("x2") + " ";
                    if (result.Length >= 47)
                    {
                        Log(logLevel, result.Trim());
                        result = string.Empty;
                    }
                } //for
                if (result.Length > 0)
                {
                    Log(logLevel, result.Trim());
                }
            }
#endif
        }