Exemplo n.º 1
0
        //
        // Note: All calls to this function should occur in administrator initiated
        // processes. No calls to this function should as a result of an HTTP request from
        // a SOAP API.
        // This is verified to be true on 3/1/2002 by creeves
        //
        public static void OperatorMail(SeverityType severity, CategoryType category, OperatorMessageType messageId, string message)
        {
            string mailTo = Config.GetString("Debug.MailTo", null);

            if (null == mailTo)
            {
                Debug.Write(
                    SeverityType.Info,
                    CategoryType.Config,
                    "Skipping send of operator mail.  Configuration setting 'Debug.MailTo' not set.");

                return;
            }

            Debug.VerifySetting("Debug.MailFrom");

            try
            {
                string mailCc      = Config.GetString("Debug.MailCc", null);
                string mailSubject = Config.GetString(
                    "Debug.MailSubject",
                    "Operator message from {0}.  Severity: {1}, Category: {2}");

                MailMessage mail = new MailMessage();

                mail.To      = mailTo;
                mail.From    = Config.GetString("Debug.MailFrom");
                mail.Subject = String.Format(
                    mailSubject,
                    System.Environment.MachineName,
                    severity.ToString(),
                    category.ToString(),
                    (int)messageId);

                if (null != mailCc)
                {
                    mail.Cc = mailCc;
                }

                mail.BodyFormat = MailFormat.Text;
                mail.Body       =
                    "SEVERITY: " + severity.ToString() + "\r\n" +
                    "CATEGORY: " + category.ToString() + "\r\n" +
                    "EVENT ID: " + (int)messageId + "\r\n\r\n" +
                    message;

                SmtpMail.Send(mail);
            }
            catch (Exception e)
            {
                Debug.OperatorMessage(
                    SeverityType.Error,
                    CategoryType.None,
                    OperatorMessageType.CouldNotSendMail,
                    "Could not send operator mail.\r\n\r\nDetails:\r\n\r\n" + e.ToString());
            }
        }
Exemplo n.º 2
0
    /// <summary>
    /// Used for player QA events
    /// </summary>
    /// <param name="businessID">
    /// The event identifier. F.x. "FailedToLoadLevel" <see cref="System.String"/>
    /// </param>
    /// <param name="message">
    /// A string detailing the event, F.x. the stack trace from an exception <see cref="System.String"/>
    /// </param>
    /// <param name="stack">
    /// If true any identical messages in the queue will be merged/stacked as a single message, to save server load
    /// </param>
    private void CreateNewEvent(SeverityType severity, string message, float? x, float? y, float? z, bool stack)
    {
        Hashtable parameters = new Hashtable()
        {
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Severity], severity.ToString() },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Message], message },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Level], GA.SettingsGA.CustomArea.Equals(string.Empty)?Application.loadedLevelName:GA.SettingsGA.CustomArea }
        };

        if (x.HasValue)
        {
            parameters.Add(GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.X], (x*GA.SettingsGA.HeatmapGridSize.x).ToString());
        }

        if (y.HasValue)
        {
            parameters.Add(GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Y], (y*GA.SettingsGA.HeatmapGridSize.y).ToString());
        }

        if (z.HasValue)
        {
            parameters.Add(GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Z], (z*GA.SettingsGA.HeatmapGridSize.z).ToString());
        }

        GA_Queue.AddItem(parameters, GA_Submit.CategoryType.GA_Error, stack);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Used for player QA events
    /// </summary>
    /// <param name="businessID">
    /// The event identifier. F.x. "FailedToLoadLevel" <see cref="System.String"/>
    /// </param>
    /// <param name="message">
    /// A string detailing the event, F.x. the stack trace from an exception <see cref="System.String"/>
    /// </param>
    /// <param name="stack">
    /// If true any identical messages in the queue will be merged/stacked as a single message, to save server load
    /// </param>
    private void CreateNewEvent(SeverityType severity, string message, float?x, float?y, float?z, bool stack)
    {
        Hashtable parameters = new Hashtable()
        {
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Severity], severity.ToString() },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Message], message },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Level], GA.SettingsGA.CustomArea.Equals(string.Empty)?Application.loadedLevelName:GA.SettingsGA.CustomArea }
        };

        if (x.HasValue)
        {
            parameters.Add(GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.X], (x * GA.SettingsGA.HeatmapGridSize.x).ToString());
        }

        if (y.HasValue)
        {
            parameters.Add(GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Y], (y * GA.SettingsGA.HeatmapGridSize.y).ToString());
        }

        if (z.HasValue)
        {
            parameters.Add(GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Z], (z * GA.SettingsGA.HeatmapGridSize.z).ToString());
        }

        GA_Queue.AddItem(parameters, GA_Submit.CategoryType.GA_Error, stack);
    }
Exemplo n.º 4
0
        /// ****************************************************************
        ///   public WriteDebugger [static]
        /// ----------------------------------------------------------------
        ///   <summary>
        ///     Writes a message to the debugger.
        ///   </summary>
        /// ----------------------------------------------------------------
        ///   <param name="severity">
        ///     The severity type.
        ///   </param>
        ///
        ///   <param name="category">
        ///     The category type.
        ///   </param>
        ///
        ///   <param name="message">
        ///     The message.
        ///   </param>
        /// ****************************************************************
        ///
        public static void WriteDebugger(SeverityType severity, CategoryType category, string message)
        {
            try
            {
                string text = string.Format(
                    "{0,-4}  {1,-4}  {2}",
                    severity.ToString().Substring(0, 4).ToUpper(),
                    category.ToString().Substring(0, 4).ToUpper(),
                    message.Replace("\r\n", "\r\n\t\t"));

                //
                // Write out the debugger message.
                //
                System.Diagnostics.Trace.WriteLine(text);
            }
            catch (Exception)
            {
                //
                // WriteDebugger is used as a last ditch logging mechanism
                // in many cases.  This should never throw an exception,
                // but if it does, there really isn't any more we can do
                // about it.  We'll simply eat the error.
                //
            }
        }
Exemplo n.º 5
0
        private void WriteError(object errorMessage, SeverityType severity, string errorCategory, IDictionary <string, object> properties)
        {
            var props = EnsureProperties(properties);

            props.Add(XFConstants.EventWriter.Message, errorMessage.ToString());
            props.Add(XFConstants.EventWriter.ErrorSeverity, severity.ToString());
            props.Add(XFConstants.EventWriter.Category, errorCategory);
            props.Add(XFConstants.EventWriter.EventType, EventTypeOption.Error);
            LocalPublish(EventTypeOption.Error, props);
        }
Exemplo n.º 6
0
        protected void SignalValidatation(string message, SeverityType severity)
        {
            int lineNumber   = 0;
            int linePosition = 0;
            var xml          = _reader as IXmlLineInfo;
            var type         = this.GetType();

            string signalMessage = null;

            if (xml != null)
            {
                lineNumber   = xml.LineNumber;
                linePosition = xml.LinePosition;

                signalMessage = string.Format(@"Parse {0}: {1} 
Line: {2}, Position: {3}  
Type: {4}.", severity.ToString(), message, lineNumber, linePosition, type.Name);
            }
            else
            {
                signalMessage = string.Format(@"Parse {0}: {1}. Type: {2}.",
                                              severity.ToString(), message, type.Name);
            }

            if (_validationAction == null)
            {
                if (severity == SeverityType.Error)
                {
                    throw new ParseException(signalMessage)
                          {
                              LineNumber = lineNumber, LinePosition = linePosition
                          };
                }
                else if (severity == SeverityType.Warning)
                {
                    System.Diagnostics.Debug.WriteLine(signalMessage, "Warning");
                }
            }
            else
            {
                _validationAction(new ValidationMessage(signalMessage, severity, lineNumber, linePosition));
            }
        }
Exemplo n.º 7
0
	/// <summary>
	/// Used for player QA events
	/// </summary>
	/// <param name="businessID">
	/// The event identifier. F.x. "FailedToLoadLevel" <see cref="System.String"/>
	/// </param>
	/// <param name="message">
	/// A string detailing the event, F.x. the stack trace from an exception <see cref="System.String"/>
	/// </param>
	/// <param name="stack">
	/// If true any identical messages in the queue will be merged/stacked as a single message, to save server load
	/// </param>
	private  void CreateNewEvent(SeverityType severity, string message, bool stack)
	{
		Hashtable parameters = new Hashtable()
		{
			{ GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Severity], severity.ToString() },
			{ GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Message], message },
			{ GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Level], GA.SettingsGA.CustomArea.Equals(string.Empty)?Application.loadedLevelName:GA.SettingsGA.CustomArea }
		};
		
		GA_Queue.AddItem(parameters, GA_Submit.CategoryType.GA_Error, stack);
	}
Exemplo n.º 8
0
    /// <summary>
    /// Used for player QA events
    /// </summary>
    /// <param name="businessID">
    /// The event identifier. F.x. "FailedToLoadLevel" <see cref="System.String"/>
    /// </param>
    /// <param name="message">
    /// A string detailing the event, F.x. the stack trace from an exception <see cref="System.String"/>
    /// </param>
    /// <param name="stack">
    /// If true any identical messages in the queue will be merged/stacked as a single message, to save server load
    /// </param>
    private void CreateNewEvent(SeverityType severity, string message, bool stack)
    {
        Hashtable parameters = new Hashtable()
        {
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Severity], severity.ToString() },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Message], message },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Level], GA.SettingsGA.CustomArea.Equals(string.Empty)?Application.loadedLevelName:GA.SettingsGA.CustomArea }
        };

        GA_Queue.AddItem(parameters, GA_Submit.CategoryType.GA_Error, stack);
    }
Exemplo n.º 9
0
        protected virtual void LogToConsole(string body, LevelType level, SeverityType severity, params object[] parameters)
        {
            string text = "";

            try
            {
                text = parameters.Length == 0 ? body : string.Format(body, parameters);
            }
            catch
            {
                text = body;
            }

            Console.WriteLine($"{DateTime.Now.ToString("HH:mm")} {level.ToString()} {severity.ToString()} | {text}");
        }
Exemplo n.º 10
0
        protected virtual void LogToConsole(string body, LevelType level, SeverityType severity, params object[] parameters)
        {
            string text = "";

            try
            {
                text = parameters.Length == 0 ? body : string.Format(body, parameters);
            }
            catch
            {
                text = body;
            }

            text = $"{DateTime.Now.ToString("HH:mm")} {level.ToString()} {severity.ToString()} | {text}";
            lock (fileLock)
            {
                File.AppendAllText(fileName, text + Environment.NewLine);
            }
        }
Exemplo n.º 11
0
        private string GetSeverityTypeString(SeverityType SeverityType)
        {
            switch (SeverityType)
            {
            case SeverityType.Fatal:
                return("Fatal");

            case SeverityType.Error:
                return("Error");

            case SeverityType.Warning:
                return("Warning");

            case SeverityType.Informational:
                return("Informational");

            default:
                throw new System.ComponentModel.InvalidEnumArgumentException(SeverityType.ToString(), (int)SeverityType, typeof(SeverityType));
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Used  to Log any data or exceptions that occured during running the program.
        /// </summary>
        /// <param name="Msg">the user friendly massage or any informations</param>
        /// <param name="category">Mean the project who have the problem or who want to write a message</param>
        /// <param name="priority">mean the important of the logging ex.High or Low</param>
        /// <param name="Type">the Type of the message ex.Error or info.</param>
        /// <param name="Properties">any addition informations</param>
        public void Log(string Msg, Category category, Priority priority, SeverityType Type, IDictionary <string, object> Properties)
        {
            #region Filling Extra properties

            if (Properties == null)
            {
                Properties = new Dictionary <string, object>();
            }

            if (!Properties.ContainsKey("Priority"))
            {
                Properties.Add("Priority", priority.ToString());
            }
            else
            {
                Properties["Priority"] = priority.ToString();
            }

            //-----------------------------------------------------
            if (!Properties.ContainsKey("Category"))
            {
                Properties.Add("Category", category.ToString());
            }
            else
            {
                Properties["Category"] = category.ToString();
            }

            //-----------------------------------------------------
            if (!Properties.ContainsKey("LogLayer"))
            {
                Properties.Add("LogLayer", Type.ToString());
            }
            else
            {
                Properties["LogLayer"] = Type.ToString();
            }

            #endregion

            #region Log Now
            logs = LogManager.GetLog("Page");

            switch (Type)
            {
            case SeverityType.Error:
            {
                logs.Error(Msg, null, Properties);
                break;
            }

            case SeverityType.Fatal:
            {
                logs.Fatal(Msg, null, Properties);
                break;
            }

            case SeverityType.Information:
            {
                logs.Info(Msg, null, Properties);
                break;
            }

            case SeverityType.Warning:
            {
                logs.Warn(Msg, null, Properties);
                break;
            }

            default:
            {
                logs.Info(Msg, null, Properties);
                break;
            }
            }

            #endregion
        }
Exemplo n.º 13
0
        /// <summary>
        /// Used  to Log any data or exceptions that occured during running the program.
        /// </summary>
        /// <param name="Msg">the user friendly massage or any informations</param>
        /// <param name="category">Mean the project who have the problem or who want to write a message</param>
        /// <param name="priority">mean the important of the logging ex.High or Low</param>
        /// <param name="Type">the Type of the message ex.Error or info.</param>
        /// <param name="Properties">any addition informations</param>
        public void Log(string Msg, Category category, Priority priority, SeverityType Type, IDictionary <string, object> Properties)
        {
            #region Filling Extra properties

            if (Properties == null)
            {
                Properties = new Dictionary <string, object>();
            }

            if (!Properties.ContainsKey("Priority"))
            {
                Properties.Add("Priority", priority.ToString());
            }
            else
            {
                Properties["Priority"] = priority.ToString();
            }

            //-----------------------------------------------------
            if (!Properties.ContainsKey("Category"))
            {
                Properties.Add("Category", category.ToString());
            }
            else
            {
                Properties["Category"] = category.ToString();
            }

            //-----------------------------------------------------
            if (!Properties.ContainsKey("LogLayer"))
            {
                Properties.Add("LogLayer", Type.ToString());
            }
            else
            {
                Properties["LogLayer"] = Type.ToString();
            }

            #endregion

            #region Log Now



            //DanielVaughan.Logging.Log.Write += new EventHandler<DanielVaughan.Logging.LogEventArgs>(Log_Write);


            switch (Type)
            {
            case SeverityType.Error:
            {
                DanielVaughan.Logging.Log.Error(Msg, null, Properties);
                break;
            }

            case SeverityType.Fatal:
            {
                DanielVaughan.Logging.Log.Fatal(Msg, null, Properties);
                break;
            }

            case SeverityType.Information:
            {
                DanielVaughan.Logging.Log.Info(Msg, null, Properties);
                break;
            }

            case SeverityType.Warning:
            {
                DanielVaughan.Logging.Log.Warn(Msg, null, Properties);
                break;
            }

            default:
            {
                DanielVaughan.Logging.Log.Info(Msg, null, Properties);
                break;
            }
            }

            #endregion
        }
Exemplo n.º 14
0
        /// ****************************************************************
        ///   public WriteFileLog [static]
        /// ----------------------------------------------------------------
        ///   <summary>
        ///     Writes a message to the file log.
        ///   </summary>
        /// ----------------------------------------------------------------
        ///   <param name="severity">
        ///     The severity type.
        ///   </param>
        ///
        ///   <param name="category">
        ///     The category type.
        ///   </param>
        ///
        ///   <param name="message">
        ///     The message.
        ///   </param>
        /// ****************************************************************
        ///
        public static void WriteFileLog(SeverityType severity, CategoryType category, string message)
        {
            readWriteLock.AcquireReaderLock(Constants.ReadLockTimeout);

            try
            {
                //
                // If the log filename has not yet been initialized, there is nothing we
                // can log yet.
                //
                if (null == logFilename)
                {
                    return;
                }

                //
                // Open the logging file, if it is not already.
                //
                if (null == textStream)
                {
                    //
                    // Get the full path to our log file.
                    //
                    string logFilePath = logFilename.GetString();

                    //
                    // Pull off the directory of the log file and see if we need to
                    // create it.
                    //
                    string logFileDirectory = Path.GetDirectoryName(logFilePath);
                    if (false == Directory.Exists(logFileDirectory))
                    {
                        Directory.CreateDirectory(logFileDirectory);
                    }

                    //
                    // Append to an existing log file, or create a new one.
                    //
                    FileStream file = File.Open(
                        logFilePath,
                        FileMode.Append,
                        FileAccess.Write,
                        FileShare.ReadWrite);

                    textStream         = TextWriter.Synchronized(new StreamWriter(file, System.Text.Encoding.UTF8));
                    textStream.NewLine = "\r\n";
                }

                //
                // Build a time string of the format: YYMMDD:hhmmss
                //
                DateTime time = DateTime.Now;

                string timeString = string.Format(
                    "{0,-4:D4}/{1:D2}/{2:D2} {3:D2}:{4:D2}:{5:D2}",
                    time.Year,
                    time.Month,
                    time.Day,
                    time.Hour,
                    time.Minute,
                    time.Second);

                //
                // Write out the file log entry.
                //
                textStream.WriteLine(
                    severity.ToString().Substring(0, 4).ToUpper() + "  " +
                    category.ToString().Substring(0, 4).ToUpper() + "  " +
                    timeString + "  " +
                    message.Replace("\r\n", "\r\n\t\t"));

                textStream.Flush();
            }
            catch (Exception e)
            {
                WriteDebugger(
                    SeverityType.Error,
                    CategoryType.None,
                    "Could not write to log file " + logFilename + ".\r\n\r\nDetails:\r\n" + e.ToString());

                //
                // If for whatever reason we could not write output to the log file, we dump the logfile name,
                // and the reason to the event log.
                //
                WriteEventLog(
                    SeverityType.Error,
                    CategoryType.None,
                    OperatorMessageType.None,
                    "Could not write to log file " + logFilename + ".\r\n\r\nDetails:\r\n" + e.ToString());
            }
            finally
            {
                readWriteLock.ReleaseReaderLock();
            }
        }