示例#1
0
        public UnityLoggerFactoryV2([Zenject.InjectOptional] GameObject gameobject, IStructuredLogEventWriter writer)
        {
            this.gameobject = gameobject;
            this.writer     = writer;

            this.config = this.GetConfig(gameobject);

            Assert.IsNotNull(this.config);
        }
示例#2
0
        private Logging GetConfig(GameObject gameobject)
        {
            // Get the Logging config from own gameobject or any parent.
            Logging config = null;

            if (gameobject != null)
            {
                config = gameobject.GetComponentInParent <Logging>();
            }

            if (config == null)
            {
                if (rootLogConfig == null)
                {
                    var rootConfigGo = GameObject.Find("Logging");

                    if (rootConfigGo == null)
                    {
                        rootConfigGo = new GameObject("Logging");
                    }

                    config = rootConfigGo.GetComponent <Logging>();

                    if (config == null)
                    {
                        config = rootConfigGo.AddComponent <Logging>();
                    }

                    rootLogConfig = config;
                }
                else
                {
                    config = rootLogConfig;
                }
            }

            return(config);
        }
示例#3
0
 public UnityLogger(ILogSource source, ILogLevelConfig config)
     : base(source, new LogLevelStatus(config))
 {
 }