Improve logging.
This commit is contained in:
		@@ -103,6 +103,7 @@ namespace zaaReloaded2.Importer.ZaaImporter
 | 
				
			|||||||
            // "HBs-Antigen: neg. ;"
 | 
					            // "HBs-Antigen: neg. ;"
 | 
				
			||||||
            // "Erythrozyten (U): + [negativ]"
 | 
					            // "Erythrozyten (U): + [negativ]"
 | 
				
			||||||
            Match match;
 | 
					            Match match;
 | 
				
			||||||
 | 
					            Logger.Debug("ParseLauris: {0}", LaurisText);
 | 
				
			||||||
            if (_numericalRegex.IsMatch(LaurisText))
 | 
					            if (_numericalRegex.IsMatch(LaurisText))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Logger.Debug("ParseLauris: Numerical match");
 | 
					                Logger.Debug("ParseLauris: Numerical match");
 | 
				
			||||||
@@ -139,10 +140,11 @@ namespace zaaReloaded2.Importer.ZaaImporter
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            if (match.Groups["limits"].Success)
 | 
					            if (match.Groups["limits"].Success)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Logger.Debug("ParseLimits: Has limits");
 | 
					                Logger.Debug("ParseLimits: Has limits: {0}", match.Groups["limits"].Value);
 | 
				
			||||||
                Match limitMatch = _limitRegex.Match(match.Groups["limits"].Value);
 | 
					                Match limitMatch = _limitRegex.Match(match.Groups["limits"].Value);
 | 
				
			||||||
                if (limitMatch.Groups["limit1"].Success && limitMatch.Groups["limit2"].Success)
 | 
					                if (limitMatch.Groups["limit1"].Success && limitMatch.Groups["limit2"].Success)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    Logger.Debug("ParseLimits: Upper and lower limit detected");
 | 
				
			||||||
                    // Use InvariantCulture because Lauris always outputs dots as decimal separator
 | 
					                    // Use InvariantCulture because Lauris always outputs dots as decimal separator
 | 
				
			||||||
                    // Only in rare cases, a comma sneaks in...
 | 
					                    // Only in rare cases, a comma sneaks in...
 | 
				
			||||||
                    LowerLimit = Double.Parse(limitMatch.Groups["limit1"].Value.Replace(',', '.'),
 | 
					                    LowerLimit = Double.Parse(limitMatch.Groups["limit1"].Value.Replace(',', '.'),
 | 
				
			||||||
@@ -152,6 +154,7 @@ namespace zaaReloaded2.Importer.ZaaImporter
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    Logger.Debug("ParseLimits: Single limit detected");
 | 
				
			||||||
                    switch (limitMatch.Groups["operator"].Value.Trim())
 | 
					                    switch (limitMatch.Groups["operator"].Value.Trim())
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        case "<=":
 | 
					                        case "<=":
 | 
				
			||||||
@@ -167,9 +170,9 @@ namespace zaaReloaded2.Importer.ZaaImporter
 | 
				
			|||||||
                            // Fixes exception ID 65ca8575.
 | 
					                            // Fixes exception ID 65ca8575.
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                        default:
 | 
					                        default:
 | 
				
			||||||
                            throw new InvalidOperationException(
 | 
					                            string unknown = match.Groups["limits"].Value;
 | 
				
			||||||
                                String.Format("Unknown operator in {0}",
 | 
					                            Logger.Fatal("ParseLimits: Unknown operator \"{0}\"", unknown);
 | 
				
			||||||
                                    match.Groups["limits"].Value));
 | 
					                            throw new InvalidOperationException(String.Format("Unknown operator in {0}",unknown));
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -110,6 +110,7 @@ namespace zaaReloaded2.Importer.ZaaImporter
 | 
				
			|||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        void Parse()
 | 
					        void Parse()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            Logger.Info("Parse: \"{0}\"", OriginalParagraph.TruncateWithEllipsis(40));
 | 
				
			||||||
            Match m = _expectedFormat.Match(OriginalParagraph);
 | 
					            Match m = _expectedFormat.Match(OriginalParagraph);
 | 
				
			||||||
            if (m.Success)
 | 
					            if (m.Success)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@@ -130,7 +131,6 @@ namespace zaaReloaded2.Importer.ZaaImporter
 | 
				
			|||||||
            else
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Logger.Info("Parse: Does not match Lauris paragraph format");
 | 
					                Logger.Info("Parse: Does not match Lauris paragraph format");
 | 
				
			||||||
                Logger.Info("Parse: {0}", OriginalParagraph.TruncateWithEllipsis(40));
 | 
					 | 
				
			||||||
                IsLaurisParagraph = false;
 | 
					                IsLaurisParagraph = false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -219,12 +219,12 @@ namespace zaaReloaded2.Importer.ZaaImporter
 | 
				
			|||||||
                // the normal format of a paragraph generated from Lauris.
 | 
					                // the normal format of a paragraph generated from Lauris.
 | 
				
			||||||
                if (m.Groups["tail"].Success)
 | 
					                if (m.Groups["tail"].Success)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Logger.Debug("ParseParagraph: Time stamp has tail, adding dummy caption");
 | 
					                    Logger.Info("ParseParagraph: Time stamp has a tail -- putting it back with a dummy caption");
 | 
				
			||||||
                    paragraph = "DUMMY CAPTION: " + m.Groups["tail"].Value;
 | 
					                    paragraph = "DUMMY CAPTION: " + m.Groups["tail"].Value;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    paragraph = String.Empty;
 | 
					                    paragraph = null;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,17 +67,19 @@ namespace zaaReloaded2.Importer.ZaaImporter
 | 
				
			|||||||
        /// <param name="text">ZAA-formatted Lauris output to import.</param>
 | 
					        /// <param name="text">ZAA-formatted Lauris output to import.</param>
 | 
				
			||||||
        public void Import(string text)
 | 
					        public void Import(string text)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Logger.Info("Import");
 | 
					            Logger.Info("Import: \"{0}\"", text.TruncateWithEllipsis(120));
 | 
				
			||||||
            string[] paragraphs = Helpers.SplitParagraphs(text);
 | 
					            string[] paragraphs = Helpers.SplitParagraphs(text);
 | 
				
			||||||
 | 
					            Logger.Info("Import: {0} paragraph(s)", paragraphs.Length);
 | 
				
			||||||
            LaurisTimePoint timePoint = null;
 | 
					            LaurisTimePoint timePoint = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            foreach (string paragraph in paragraphs)
 | 
					            foreach (string paragraph in paragraphs)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					                Logger.Info("Import: \"{0}\"", paragraph.TruncateWithEllipsis(40));
 | 
				
			||||||
                // If the current paragraph looks like a Lauris time stamp,
 | 
					                // If the current paragraph looks like a Lauris time stamp,
 | 
				
			||||||
                // create a new time point.
 | 
					                // create a new time point.
 | 
				
			||||||
                if (LaurisTimePoint.IsTimeStampLine(paragraph))
 | 
					                if (LaurisTimePoint.IsTimeStampLine(paragraph))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Logger.Info("Import: Time stamp line: {0}", paragraph);
 | 
					                    Logger.Info("Import: Time stamp detected", paragraph);
 | 
				
			||||||
                    timePoint = new LaurisTimePoint(paragraph, _parameters, _units);
 | 
					                    timePoint = new LaurisTimePoint(paragraph, _parameters, _units);
 | 
				
			||||||
                    // Add the time point to the laboratory only if none
 | 
					                    // Add the time point to the laboratory only if none
 | 
				
			||||||
                    // with the same time stamp exists yet.
 | 
					                    // with the same time stamp exists yet.
 | 
				
			||||||
@@ -106,8 +108,7 @@ namespace zaaReloaded2.Importer.ZaaImporter
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Logger.Debug("Import: Neither time line, nor Lauris paragraph");
 | 
					                    Logger.Debug("Import: Neither time stamp, nor Lauris paragraph");
 | 
				
			||||||
                    Logger.Debug("Import: {0}", paragraph.TruncateWithEllipsis(30));
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user