示例#1
0
        /// <summary>
        /// Writes information about an exception into the log to the sandbox.
        /// </summary>
        /// <param name="exception">The exception to write into the log.</param>
        /// <param name="eventId">The eventId that corresponds to the event. This value, coupled with the EventSource is often used by
        /// administrators and IT PRo's to monitor the EventLog of a system.</param>
        /// <param name="severity">The severity of the exception.</param>
        /// <param name="category">The category to write the message to.</param>
        public void LogToOperations(Exception exception, int eventId, SandboxEventSeverity severity,
                                    string category)
        {
            Validation.ArgumentNotNull(exception, "exception");

            WriteLogMessage(BuildExceptionMessage(exception, null), eventId, severity, category);
        }
示例#2
0
        protected override void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category)
        {
            var messageToAdd = new LoggedMessage();

            messageToAdd.Message = message;
            messageToAdd.EventId = eventId;
            messageToAdd.SandboxEventSeverity = severity;
            messageToAdd.Category             = category;
            Messages.Add(messageToAdd);
        }
            public TestLogger()
            {
                LogToOperationsStringInt32SandboxEventSeverityString = (message, eventId, eventSeverity, category) =>
                {
                    this.Message  = message;
                    this.EventId  = eventId;
                    this.Category = category;
                    this.Severity = eventSeverity;
                };

                LogToOperationsStringInt32String = (message, eventId, category) =>
                {
                    this.Message  = message;
                    this.EventId  = eventId;
                    this.Category = category;
                };
            }
示例#4
0
 protected override void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category)
 {
     try
     {
         if (SharePointEnvironment.InSandbox)
         {
             WriteToOperationsLogSandbox(message, eventId, severity, category);
         }
         else
         {
             WriteToOperationsLogFullTrust(message, eventId, severity, category);
         }
     }
     catch (Exception ex)
     {
         // If the logging failed, throw an error that holds both the original error information and the
         // reason why logging failed. Dont do this if only the tracing failed.
         throw BuildLoggingException(message, ex);
     }
 }
示例#5
0
 public void LogToOperations(Exception exception, int eventId, SandboxEventSeverity severity, string category)
 {
 }
示例#6
0
 /// <summary>
 /// Translates a <see cref="SandboxEventSeverity"/> into an EventSeverity.
 /// SandboxEventSeverity uses same enum values.
 /// </summary>
 /// <param name="severity">The severity of the event</param>
 /// <returns>the equlivalent SharePoint EventSeverity value</returns>
 public EventSeverity GetEventSeverity(SandboxEventSeverity severity)
 {
     return((EventSeverity)((int)severity));
 }
示例#7
0
 protected override void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category)
 {
     try
     {
         if (SharePointEnvironment.InSandbox)
             WriteToOperationsLogSandbox(message, eventId, severity, category);
         else
             WriteToOperationsLogFullTrust(message, eventId, severity, category);
     }
     catch (Exception ex)
     {
         // If the logging failed, throw an error that holds both the original error information and the 
         // reason why logging failed. Dont do this if only the tracing failed. 
         throw BuildLoggingException(message, ex);
     }
 }
示例#8
0
 /// <summary>
 /// Override this method to implement how to write to a log message for the sandbox
 /// </summary>
 /// <param name="message">The message to write into the log.</param>
 /// <param name="eventId">
 /// The eventId that corresponds to the event. This value, coupled with the EventSource is often used by
 /// administrators and IT PRo's to monitor the EventLog of a system. 
 /// </param>
 /// <param name="severity">How serious the event is. </param>
 /// <param name="category">The category of the log message.</param>
 protected abstract void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category);
示例#9
0
 /// <summary>
 /// Safe method to trace to the sandbox.
 /// </summary>
 /// <param name="message">The message to trace</param>
 /// <param name="eventId">the event id to trace</param>
 /// <param name="severity">the sandbox severity to use</param>
 /// <param name="category">The category to trace under</param>
 private void WriteLogMessage(string message, int eventId, SandboxEventSeverity severity, string category)
 {
     string logMsg = BuildEventLogMessage(message, eventId, severity, category);
     WriteToOperationsLog(logMsg, eventId, severity, category);
 }
示例#10
0
        /// <summary>
        /// Writes the logged message to the operations log from the sandbox.
        /// </summary>
        /// <param name="message">The message to write into the log.</param>
        /// <param name="eventId">
        /// The eventId that corresponds to the event. This value, coupled with the EventSource is often used by
        /// administrators and IT PRo's to monitor the EventLog of a system. 
        /// </param>
        /// <param name="severity">How serious the event is. </param>
        /// <param name="category">The category of the log message.</param>
        public void LogToOperations(string message, int eventId, SandboxEventSeverity severity, string category)
        {
            Validation.ArgumentNotNull(message, "message");

            WriteLogMessage(message, eventId, severity, category);
        }
示例#11
0
        /// <summary>
        /// Writes the logged message to the operations log from the sandbox.
        /// </summary>
        /// <param name="message">The message to write into the log.</param>
        /// <param name="eventId">
        /// The eventId that corresponds to the event. This value, coupled with the EventSource is often used by
        /// administrators and IT PRo's to monitor the EventLog of a system.
        /// </param>
        /// <param name="severity">How serious the event is. </param>
        /// <param name="category">The category of the log message.</param>
        public void LogToOperations(string message, int eventId, SandboxEventSeverity severity, string category)
        {
            Validation.ArgumentNotNull(message, "message");

            WriteLogMessage(message, eventId, severity, category);
        }
示例#12
0
        /// <summary>
        /// Writes an error message into the log from the sandbox.  WIll
        /// work from outside the sandbox as well.
        /// </summary>
        /// <param name="message">The message to write</param>
        /// <param name="severity">How serious the event is.</param>
        public void LogToOperations(string message, SandboxEventSeverity severity)
        {
            Validation.ArgumentNotNull(message, "message");

            WriteLogMessage(message, DefaultEventId, severity, null);
        }
示例#13
0
 /// <summary>
 /// Translates a <see cref="SandboxEventSeverity"/> into an EventSeverity.
 /// SandboxEventSeverity uses same enum values.
 /// </summary>
 /// <param name="severity">The severity of the event</param>
 /// <returns>the equlivalent SharePoint EventSeverity value</returns>
 public EventSeverity GetEventSeverity(SandboxEventSeverity severity)
 {
     return (EventSeverity)((int)severity);
 }
示例#14
0
 private void WriteToOperationsLogFullTrust(string message, int eventId, SandboxEventSeverity severity, string category)
 {
     EventLogLogger.Log(message, eventId, GetEventSeverity(severity), category);
 }
示例#15
0
        protected virtual void WriteToOperationsLogSandbox(string message, int eventId, SandboxEventSeverity? severity, string category)
        {
            if (SharePointLogger.canAccessSandboxLogging == -1)
            {
                if (SharePointEnvironment.ProxyInstalled(TracingOperationArgs.OperationAssemblyName, TracingOperationArgs.OperationTypeName))
                {
                    SharePointLogger.canAccessSandboxTracing = 1;
                }
                else
                {
                    SharePointLogger.canAccessSandboxTracing = 0;
                }
            }

            if (SharePointLogger.canAccessSandboxTracing == 1)
            {
                var args = new LoggingOperationArgs();
                args.Message = message;
                args.EventId = eventId;
                args.Category = category;
                args.Severity = (int?)severity;

                if (SPContext.Current != null)
                    args.SiteID = SPContext.Current.Site.ID;
                else
                    args.SiteID = null;

                var result = SPUtility.ExecuteRegisteredProxyOperation(
                                        LoggingOperationArgs.OperationAssemblyName,
                                         LoggingOperationArgs.OperationTypeName,
                                         args);

                if (result != null && result.GetType().IsSubclassOf(typeof(System.Exception)))
                {
                    var ex = new LoggingException(Properties.Resources.SandboxLoggingFailed, (Exception)result);
                    throw ex;
                }
            }

        }
示例#16
0
 public void LogToOperations(string message, int eventId, SandboxEventSeverity severity, string category)
 {
 }
示例#17
0
 public void LogToOperations(string message, SandboxEventSeverity severity)
 {
 }
示例#18
0
        /// <summary>
        /// Safe method to trace to the sandbox.
        /// </summary>
        /// <param name="message">The message to trace</param>
        /// <param name="eventId">the event id to trace</param>
        /// <param name="severity">the sandbox severity to use</param>
        /// <param name="category">The category to trace under</param>
        private void WriteLogMessage(string message, int eventId, SandboxEventSeverity severity, string category)
        {
            string logMsg = BuildEventLogMessage(message, eventId, severity, category);

            WriteToOperationsLog(logMsg, eventId, severity, category);
        }
示例#19
0
        /// <summary>
        /// Writes an error message into the log from the sandbox.  WIll
        /// work from outside the sandbox as well.
        /// </summary>
        /// <param name="message">The message to write</param>
        /// <param name="severity">How serious the event is.</param>
        public void LogToOperations(string message, SandboxEventSeverity severity)
        {
            Validation.ArgumentNotNull(message, "message");

            WriteLogMessage(message, DefaultEventId, severity, null);
        }
示例#20
0
 /// <summary>
 /// Override this method to change the way the log message is created for the sandbox
 /// </summary>
 /// <param name="message">The message to write into the log.</param>
 /// <param name="eventId">
 /// The event Id that corresponds to the event. This value, coupled with the EventSource is often used by
 /// administrators and IT PRo's to monitor the EventLog of a system.
 /// </param>
 /// <param name="severity">How serious the event is. </param>
 /// <param name="category">The category of the log message.</param>
 /// <returns>The message.</returns>
 protected virtual string BuildEventLogMessage(string message, int eventId, SandboxEventSeverity severity,
                                               string category)
 {
     return(message);
 }
示例#21
0
        /// <summary>
        /// Writes information about an exception into the log from the sandbox.
        /// </summary>
        /// <param name="exception">The exception to write into the log to be read by operations.</param>
        /// <param name="additionalMessage">Additional information about the exception message.</param>
        /// <param name="eventId">The eventId that corresponds to the event. This value, coupled with the EventSource is often used by
        /// administrators and IT PRo's to monitor the EventLog of a system.</param>
        /// <param name="severity">The severity of the exception.</param>
        /// <param name="category">The category to write the message to.</param>
        public void LogToOperations(Exception exception, string additionalMessage, int eventId,
                                             SandboxEventSeverity severity, string category)
        {
            Validation.ArgumentNotNull(exception, "exception");
            Validation.ArgumentNotNull(additionalMessage, "additionalMessage");

            WriteLogMessage(BuildExceptionMessage(exception, additionalMessage), eventId, severity, category);
        }
示例#22
0
 /// <summary>
 /// Override this method to implement how to write to a log message for the sandbox
 /// </summary>
 /// <param name="message">The message to write into the log.</param>
 /// <param name="eventId">
 /// The eventId that corresponds to the event. This value, coupled with the EventSource is often used by
 /// administrators and IT PRo's to monitor the EventLog of a system.
 /// </param>
 /// <param name="severity">How serious the event is. </param>
 /// <param name="category">The category of the log message.</param>
 protected abstract void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category);
示例#23
0
 /// <summary>
 /// Override this method to change the way the log message is created for the sandbox 
 /// </summary>
 /// <param name="message">The message to write into the log.</param>
 /// <param name="eventId">
 /// The event Id that corresponds to the event. This value, coupled with the EventSource is often used by
 /// administrators and IT PRo's to monitor the EventLog of a system. 
 /// </param>
 /// <param name="severity">How serious the event is. </param>
 /// <param name="category">The category of the log message.</param>
 /// <returns>The message.</returns>
 protected virtual string BuildEventLogMessage(string message, int eventId, SandboxEventSeverity severity,
                                           string category)
 {
     return message;
 }
示例#24
0
 private void WriteToOperationsLogFullTrust(string message, int eventId, SandboxEventSeverity severity, string category)
 {
     EventLogLogger.Log(message, eventId, GetEventSeverity(severity), category);
 }
 protected override void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category)
 {
     throw new NotImplementedException();
 }
示例#26
0
 protected override void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category)
 {
     ErrorMessage = message;
 }