public void LogBatch(Log.PriorityFlags logLevel, StructuredLogObject logObject, LogChannelType channel = LogChannelType.Default)
 {
     if (!clubPenguinClient.OfflineMode)
     {
         LogParameters logParameters = new LogParameters();
         logParameters.logName  = channel.ToString();
         logParameters.severity = logLevelsToString[logLevel];
         logParameters.message  = Service.Get <JsonService>().Serialize(logObject);
         logParametersList.Add(logParameters);
     }
 }
 public void LogImmediate(Log.PriorityFlags logLevel, StructuredLogObject logObject, LogChannelType channel = LogChannelType.Default)
 {
     if (!clubPenguinClient.OfflineMode)
     {
         LogParameters logParameters = new LogParameters();
         logParameters.logName  = channel.ToString();
         logParameters.severity = logLevelsToString[logLevel];
         logParameters.message  = Service.Get <JsonService>().Serialize(logObject);
         logParametersList.Add(logParameters);
         APICall <PostDiagnosticsLogOperation> aPICall = PostDiagnosticsLog(logParametersList);
         aPICall.OnComplete += onPostDiagnosticsLog;
         aPICall.Execute();
     }
 }
Пример #3
0
        public static void ParseTypesToLog(Log log, string typeField)
        {
            if (string.IsNullOrEmpty(typeField) || typeField.Trim().Length == 0)
            {
                return;
            }
            string[] array = typeField.Split(':');
            string   text  = array[0].Trim();

            Log.PriorityFlags flags = Log.PriorityFlags.ALL;
            if (array.Length > 1)
            {
                try
                {
                    flags = (Log.PriorityFlags)Enum.Parse(typeof(Log.PriorityFlags), array[1]);
                }
                catch (Exception ex)
                {
                    Debug.LogWarning(string.Concat(ex, " parsing ", array[1], " for type ", text, " defaulting to ALL"));
                }
            }
            MapTypeAndFlags(log, text, flags);
        }
Пример #4
0
 public void LogBatch(Log.PriorityFlags logLevel, StructuredLogObject logObject, LogChannelType channel = LogChannelType.Default)
 {
     clubPenguinClient.DiagnosticsApi.LogBatch(logLevel, logObject, channel);
 }
Пример #5
0
        private IEnumerator runOffline()
        {
            yield return(null);

            if (Log.Instance.ShouldLogMessage(Log.PriorityFlags.DEBUG, this))
            {
                try
                {
                    FieldInfo[] fields = operation.GetType().GetFields();
                    foreach (FieldInfo fieldInfo in fields)
                    {
                        if (fieldInfo.GetCustomAttributes(typeof(HttpRequestJsonBodyAttribute), inherit: true).Length <= 0)
                        {
                            continue;
                        }
                        object obj = fieldInfo.GetValue(operation);
                        if (isSubclassOfRawGeneric(fieldInfo.FieldType, typeof(SignedResponse <>)))
                        {
                            MethodInfo method = GetType().GetMethod("castSignedResponse", BindingFlags.Static | BindingFlags.NonPublic);
                            if (method != null)
                            {
                                MethodInfo methodInfo = method.MakeGenericMethod(fieldInfo.FieldType.GetGenericArguments()[0]);
                                if (methodInfo != null)
                                {
                                    obj = methodInfo.Invoke(null, new object[1] {
                                        obj
                                    });
                                }
                            }
                        }
                        Service.Get <JsonService>().Serialize(obj);
                        break;
                    }
                }
                catch (Exception)
                {
                }
            }
            Log.PriorityFlags responseLogLevel = Log.PriorityFlags.DEBUG;
            HttpResponse      response;

            try
            {
                response = operation.GetOfflineResponse();
            }
            catch (Exception ex2)
            {
                Log.LogException(this, ex2);
                response         = new HttpResponse(new HttpRequest(new HttpRequestModel.HttpRequestModelResult()), 0.1f, new Dictionary <string, string>(), "{\"code\":999}", "{\"code\":999}", new byte[0], HttpStatusCode.InternalServerError);
                responseLogLevel = Log.PriorityFlags.ERROR;
            }
            if (Log.Instance.ShouldLogMessage(responseLogLevel, this))
            {
                try
                {
                    FieldInfo[] fields = operation.GetType().GetFields();
                    foreach (FieldInfo fieldInfo in fields)
                    {
                        if (fieldInfo.GetCustomAttributes(typeof(HttpResponseJsonBodyAttribute), inherit: true).Length <= 0)
                        {
                            continue;
                        }
                        object obj = fieldInfo.GetValue(operation);
                        if (isSubclassOfRawGeneric(fieldInfo.FieldType, typeof(SignedResponse <>)))
                        {
                            MethodInfo method = GetType().GetMethod("castSignedResponse", BindingFlags.Static | BindingFlags.NonPublic);
                            if (method != null)
                            {
                                MethodInfo methodInfo = method.MakeGenericMethod(fieldInfo.FieldType.GetGenericArguments()[0]);
                                if (methodInfo != null)
                                {
                                    obj = methodInfo.Invoke(null, new object[1] {
                                        obj
                                    });
                                }
                            }
                        }
                        if (obj != null)
                        {
                            Service.Get <JsonService>().Serialize(obj);
                        }
                        break;
                    }
                }
                catch (Exception)
                {
                }
            }
            if (response.Is2XX || response.Is100)
            {
                this.OnResponse.InvokeSafe(operation, response);
            }
            if (!response.Is2XX && !response.Is100)
            {
                this.OnError.InvokeSafe(operation, response);
            }
            this.OnComplete.InvokeSafe(operation, response);
        }
Пример #6
0
        private void initWAK(string apiUrl, string clientToken, string clientApiVersion)
        {
            Configuration.SetSetting("log-internal", false);
            Configuration.SetSetting("log-VERBOSE", false);
            Configuration.SetSetting("log-DEBUG", true);
            Configuration.SetSetting("log-INFO", true);
            Configuration.SetSetting("log-WARNING", true);
            Configuration.SetSetting("log-ERROR", true);
            Configuration.SetSetting("log-callback", (Action <string, LogSeverity>) delegate(string message, LogSeverity severity)
            {
                switch (severity)
                {
                case LogSeverity.ERROR:
                    {
                        Log.PriorityFlags priorityFlags = Log.PriorityFlags.NETWORK_ERROR;
                        break;
                    }

                case LogSeverity.WARNING:
                    {
                        Log.PriorityFlags priorityFlags = Log.PriorityFlags.WARNING;
                        break;
                    }

                case LogSeverity.INFO:
                    {
                        Log.PriorityFlags priorityFlags = Log.PriorityFlags.INFO;
                        break;
                    }

                case LogSeverity.DEBUG:
                    {
                        Log.PriorityFlags priorityFlags = Log.PriorityFlags.DEBUG;
                        break;
                    }

                case LogSeverity.VERBOSE:
                    {
                        Log.PriorityFlags priorityFlags = Log.PriorityFlags.TRACE;
                        break;
                    }

                default:
                    {
                        Log.PriorityFlags priorityFlags = Log.PriorityFlags.NONE;
                        break;
                    }
                }
            });
            Configuration.SetSetting("destroy-operation-on-completion", false);
            Configuration.SetSetting("persistent-game-object-name", "com.clubpenguin/WebApiKit");
            Configuration.SetSetting("default-http-client", typeof(HttpWWWClient));
            Configuration.SetSetting("request-timeout", 35f);
            Configuration.SetSetting("yield-time", 0f);
            Configuration.SetSetting("default-json-serializer", typeof(SerializeLitJson));
            Configuration.SetSetting("default-json-deserializer", typeof(DeserializeLitJson));
            Configuration.SetBaseUri("cp-api-base-uri", apiUrl);
            Configuration.SetSetting("cp-api-client-token", clientToken);
            Configuration.SetSetting("cp-api-client-version", clientApiVersion);
            if (AccessToken != null)
            {
                Configuration.SetSetting("cp-api-username", AccessToken);
            }
            setWakContentVersionFromContentSystem();
            Service.Get <EventDispatcher>().AddListener <Content.ContentManifestUpdated>(onContentManifestUpdated);
            Configuration.Bootstrap();
        }
Пример #7
0
        private static void MapTypeAndFlags(Log log, string typeName, Log.PriorityFlags flags)
        {
            string text = typeName;
            bool   flag = false;

            if (typeName.StartsWith("!"))
            {
                flag = true;
                text = typeName.Substring(1);
            }
            if (text.Equals("ALL", StringComparison.OrdinalIgnoreCase))
            {
                log.LogAllTypes           = true;
                log.LogAllTypesPriorities = flags;
                return;
            }
            if (text.Equals("NONE", StringComparison.OrdinalIgnoreCase))
            {
                log.ExcludeAllTypes = true;
                return;
            }
            if (text.Equals("NULL", StringComparison.OrdinalIgnoreCase))
            {
                if (flag)
                {
                    log.NullPriorityFlags  = flags;
                    log.ExcludeNullObjects = true;
                }
                else
                {
                    log.NullPriorityFlags  = flags;
                    log.ExcludeNullObjects = false;
                }
                return;
            }
            Type type = Type.GetType(text);

            if (type == null)
            {
                Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
                foreach (Assembly assembly in assemblies)
                {
                    type = assembly.GetType(text);
                    if (type != null)
                    {
                        break;
                    }
                }
            }
            if (type != null)
            {
                if (flag)
                {
                    log.SetNotLogFlags(type, flags);
                }
                else
                {
                    log.SetLogFlags(type, flags);
                }
            }
            else
            {
                Debug.LogError("LogConfigurator: Could not find type: " + text);
            }
        }