Exemple #1
0
    private void HandleOnLog(Log.LogTypes type, string message)
    {
        switch (type)
        {
        case Log.LogTypes.Trace:
        default:
            Debug.Log(message);
            break;

        case Log.LogTypes.Error:
            Debug.LogError(message);
            break;

        case Log.LogTypes.Warning:
            Debug.LogWarning(message);
            break;
        }
    }
        /// <summary>
        /// Sets the proper log methods depending on the configuration found in the .config file
        /// </summary>
        public static void SetLogger()
        {
            // Initialize the different log types
            Log.LogTypes LoggingTypes = Log.LogTypes.Message | Log.LogTypes.Warning;

            // If we're in debug mode, heighten the logging which takes place
            if (ConfigurationReader.IsDebug)
            {
                LoggingTypes |= Log.LogTypes.Debug | Log.LogTypes.Exception | Log.LogTypes.Error;

                // Check if we need to write logs to a file
                string logFile = ConfigurationReader.LogFile;
                if (!string.IsNullOrEmpty(logFile))
                {
                    // Try to create a stream using the log file
                    try
                    {
                        FileStream logStream = File.Create(logFile);
                        Log.SetStream(logStream, true, LoggingTypes);

                        return;
                    }
                    // In the event of failure, log to console instead
                    catch (Exception e)
                    {
                        Log.SetStream(Console.OpenStandardOutput(), false, LoggingTypes);
                        Log.Exception(e, logFile);

                        return;
                    }
                }

                // If no log file is specified, log to console instead
                Log.SetStream(Console.OpenStandardOutput(), false, LoggingTypes);

                //Log.Warning("No log file specified. All logs written to console.");
                return;
            }
            // If not in debug mode, write messages to console
            Log.SetStream(Console.OpenStandardOutput(), false, LoggingTypes);
        }
Exemple #3
0
 public void Add(string message, Log.LogTypes logType)
 {
     this.Add(new Log(message, logType));
 }