CPlan.W3LF.Logging.Log C# (CSharp) Method

Log() public static method

public static Log ( LogLevels level, string text ) : void
level LogLevels
text string
return void
        public static void Log(LogLevels level, string text)
        {
#if LOG
            if (!File.Exists(LogPath))
            {
                File.WriteAllText(LogPath, "Executable: " + Application.ExecutablePath + "\r\n" +
                    "Version: " + Application.ProductVersion + "\r\n" +
                    "Installed .Net Framework: " + typeof(object).Assembly.GetName().Version.ToString() + "\r\n" +
                    "OS: " + Environment.OSVersion.VersionString + "\r\n", Encoding.UTF8);
            }
            switch (level)
            {
                case LogLevels.Warning:
                    text = "[WARN] " + text;
                    break;
                case LogLevels.Error:
                    text = "[ERRO] " + text;
                    break;
                case LogLevels.Information:
                default:
                    text = "[INFO] " + text;
                    break;
            }
            File.AppendAllLines(LogPath, new string[] { text }, Encoding.UTF8);
#endif
        }
        /// <summary>

Usage Example

 /// <summary>
 /// Initializes the <see cref="CPlan.W3LF.Settings.W3Path"/> property.
 /// </summary>
 public static void InitPath()
 {
     W3Path = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32).OpenSubKey("Software\\Blizzard Entertainment\\Warcraft III").GetValue("InstallPath", "C:\\Progra~1\\Warcra~1").ToString();
     Logging.Log(Logging.LogLevels.Information, "Using W3Path: " + W3Path);
 }
Logging