예제 #1
0
        protected override void Append(LoggingEvent loggingEvent)
        {
            var summary = Layout != null ? RenderLoggingEvent(loggingEvent) : loggingEvent.MessageObject.ToString();

            var issue = new RemoteIssue
            {
                project = ProjectKey,
                type = IssueTypeId,
                summary = summary.Truncate(SummaryMaxCharCount)
            };
            if (!string.IsNullOrEmpty(AssigneeUsername)) issue.assignee = AssigneeUsername;
            if (!string.IsNullOrEmpty(ComponentId)) issue.components = new[] { new RemoteComponent { id = ComponentId } };
            var description = new StringBuilder();
            if (summary.Length > SummaryMaxCharCount) description.AppendFormat("Message: {0}\n", summary);
            description.AppendFormat("Level: {0}\n", loggingEvent.Level);
            description.AppendFormat("Logger: {0}\n", loggingEvent.LoggerName);
            if (loggingEvent.ExceptionObject != null)
            {
                description.Append("\n{code:title=Exception}");
                description.Append(loggingEvent.GetExceptionString());
                description.Append("{code}");
            }
            issue.description = description.ToString();

            var service = new JiraSoapServiceService { Url = Url };
            var token = service.login(Username, Password);
            LogLog.Debug(string.Format("Sending request to JIRA: {0}", issue.ToJson()));
            var returnedIssue = service.createIssue(token, issue);
            LogLog.Debug(string.Format("Got response from JIRA: {0}", returnedIssue.ToJson()));
            LogLog.Debug(string.Format("Created issue: {0}", returnedIssue.key));
        }
예제 #2
0
파일: Jira.cs 프로젝트: bjovas/Logira
        internal static RemoteIssue CreateIssue(string token, RemoteIssue remoteIssue)
        {
            if (!IsConfigured)
                throw new InvalidOperationException("JIRA is not configured");

            if (Log.IsDebugEnabled)
                Log.DebugFormat("Creating issue:\n{0}", remoteIssue.ToJson());

            remoteIssue = Service.createIssue(token, remoteIssue);

            if (Log.IsDebugEnabled)
                Log.DebugFormat("Successfully created issue:\n{0}", remoteIssue.ToJson());

            return remoteIssue;
        }