Exemple #1
0
        /// <summary>
        /// Sets the reference to the default logger configuration.
        /// </summary>
        public static void FixDefaultLoggerReference()
        {
            Log4NetConfiguration config = Resources.Load <Log4NetConfiguration>("LoggerConfiguration");

            config.DefaultConfig = GetDefaultConfig();
            EditorUtility.SetDirty(config);
            AssetDatabase.SaveAssets();
        }
Exemple #2
0
        /// <summary>
        /// Create the logger configuration scriptable in the resources folder.
        /// </summary>
        public static void CreateLoggerConfigInResources()
        {
            if (!Directory.Exists("Assets/Resources"))
            {
                Directory.CreateDirectory("Assets/Resources");
            }

            Log4NetConfiguration config = ScriptableObject.CreateInstance <Log4NetConfiguration>();

            config.DefaultConfig = GetDefaultConfig();
            AssetDatabase.CreateAsset(config, "Assets/Resources/LoggerConfiguration.asset");
            AssetDatabase.SaveAssets();
        }
Exemple #3
0
        /// <summary>
        /// Retrieves the config for the logging system.
        /// </summary>
        /// <param name="configOriginMessage">A string that says where the config came from.</param>
        /// <returns>The config file info object.</returns>
        public static FileInfo GetConfig(out string configOriginMessage)
        {
            Log4NetConfiguration config = Resources.Load <Log4NetConfiguration>("LoggerConfiguration");

            if (config.AlwaysOverride || !ConfigExistsInPersistent)
            {
                string configString = config.DefaultConfig.DefaultConfig;

                File.WriteAllText(Application.persistentDataPath + "/log4net.xml", configString);

                configOriginMessage = "Loaded default logger configuration from resources.";
            }
            else
            {
                configOriginMessage = "Loaded logger configuration from persistent path.";
            }

            FileInfo fileInfo = new FileInfo(Application.persistentDataPath + "/log4net.xml");

            return(fileInfo);
        }