Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1894_RoutePlanning/HeuristicLab.Algorithms.GraphRouting/3.3/Utilities/Logger.cs @ 16310

Last change on this file since 16310 was 8527, checked in by spimming, 12 years ago

#1894:

  • introduced heap interface
  • various heap implementation used as priority queues
  • very simple logger added
  • various versions of Astar algorithm
File size: 1.2 KB
Line 
1using System;
2using System.IO;
3
4namespace HeuristicLab.Algorithms.GraphRouting.Utilities {
5  public static class Logger {
6    //public static void writeToLogFile(string logMessage) {
7    //  string strLogMessage = string.Empty;
8    //  string strLogFile = "LogFile.txt";
9    //  StreamWriter swLog;
10
11    //  //strLogMessage = string.Format("{0}: {1}", DateTime.Now, logMessage);
12    //  strLogMessage = logMessage;
13
14    //  if (!File.Exists(strLogFile)) {
15    //    swLog = new StreamWriter(strLogFile);
16    //  } else {
17    //    swLog = File.AppendText(strLogFile);
18    //  }
19
20    //  swLog.WriteLine(strLogMessage);
21    //  swLog.WriteLine();
22
23    //  swLog.Close();
24
25    //}
26
27    static StreamWriter LogWriter;
28
29    public static void LogToFile(string message) {
30      try {
31        if (!File.Exists("LogFile.txt")) {
32          LogWriter = new StreamWriter("LogFile.txt");
33        } else {
34          LogWriter = File.AppendText("LogFile.txt");
35        }
36        LogWriter.WriteLine(message);
37        LogWriter.Flush();
38      }
39      catch (Exception) { }
40      finally {
41        if (LogWriter != null) {
42          LogWriter.Close();
43        }
44      }
45    }
46  }
47}
Note: See TracBrowser for help on using the repository browser.