[735] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
[718] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
| 25 | using System.Text;
|
---|
| 26 | using System.Diagnostics;
|
---|
[1802] | 27 | using HeuristicLab.Tracing;
|
---|
[718] | 28 |
|
---|
| 29 | namespace HeuristicLab.Hive.Client.Common {
|
---|
[735] | 30 | /// <summary>
|
---|
| 31 | /// The Logging class uses the Windows Event logging mechanism. It writes the logs to a custom log
|
---|
| 32 | /// called "Hive Client". For the creation of the Hive Client Log the program must be executed with
|
---|
| 33 | /// Administrator privileges
|
---|
| 34 | /// </summary>
|
---|
[718] | 35 | public class Logging {
|
---|
[729] | 36 | private static Logging instance = null;
|
---|
[735] | 37 | /// <summary>
|
---|
| 38 | /// This is an implementation of the singleton design pattern.
|
---|
| 39 | /// </summary>
|
---|
| 40 | /// <returns>the instance of the logger</returns>
|
---|
[1371] | 41 | public static Logging Instance {
|
---|
| 42 | get {
|
---|
| 43 | if (instance == null)
|
---|
| 44 | instance = new Logging();
|
---|
| 45 | return instance;
|
---|
| 46 | }
|
---|
| 47 | set {}
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | static Logging GetInstance() {
|
---|
[729] | 51 | if (instance == null)
|
---|
| 52 | instance = new Logging();
|
---|
| 53 | return instance;
|
---|
[718] | 54 | }
|
---|
| 55 |
|
---|
[739] | 56 | private Logging() {
|
---|
[1798] | 57 | //eventLogger = new EventLog("Hive Client");
|
---|
[718] | 58 | }
|
---|
| 59 |
|
---|
[735] | 60 | /// <summary>
|
---|
| 61 | /// Writes an Info Log-Entry
|
---|
| 62 | /// </summary>
|
---|
| 63 | /// <param name="source">string representation of the caller</param>
|
---|
| 64 | /// <param name="message">the message</param>
|
---|
[729] | 65 | public void Info(String source, String message) {
|
---|
[1931] | 66 | HiveLogger.Info(source + ": " + message);
|
---|
[1798] | 67 |
|
---|
[1802] | 68 | //DateTime current = DateTime.Now;
|
---|
| 69 | ///Debug.WriteLine(current + " - " + source + ": " + message);
|
---|
| 70 |
|
---|
[1798] | 71 | // eventLogger.Source = source;
|
---|
| 72 | // eventLogger.WriteEntry(message);
|
---|
| 73 | // eventLogger.Close();
|
---|
[718] | 74 | }
|
---|
[729] | 75 |
|
---|
[735] | 76 | /// <summary>
|
---|
| 77 | /// Writes an Error Log-Entry
|
---|
| 78 | /// </summary>
|
---|
| 79 | /// <param name="source">string representation of the caller</param>
|
---|
| 80 | /// <param name="message">the message</param>
|
---|
[729] | 81 | public void Error(String source, String message) {
|
---|
[1931] | 82 | HiveLogger.Error(source + ": " + message);
|
---|
[1798] | 83 |
|
---|
[1802] | 84 | //DateTime current = DateTime.Now;
|
---|
| 85 | //Debug.WriteLine(current + " - " + source + ": " + message);
|
---|
| 86 |
|
---|
[1798] | 87 | //eventLogger.Source = source;
|
---|
[1775] | 88 | //, EventLogEntryType.Error
|
---|
[1798] | 89 | //eventLogger.WriteEntry(message);
|
---|
| 90 | //eventLogger.Close();
|
---|
[729] | 91 | }
|
---|
| 92 |
|
---|
[735] | 93 | /// <summary>
|
---|
| 94 | /// Writes an Error Log-Entry
|
---|
| 95 | /// </summary>
|
---|
| 96 | /// <param name="source">string representation of the caller</param>
|
---|
| 97 | /// <param name="message">the message</param>
|
---|
| 98 | /// <param name="e">the exception</param>
|
---|
[729] | 99 | public void Error(String source, String message, Exception e) {
|
---|
[1931] | 100 | HiveLogger.Error(source + ": " + message, e);
|
---|
[1802] | 101 | //DateTime current = DateTime.Now;
|
---|
| 102 | //Debug.WriteLine(current + " - " + source + ": " + e + message);
|
---|
[1798] | 103 | // eventLogger.Source = source;
|
---|
| 104 | // eventLogger.WriteEntry(message +"\n" + e.ToString());
|
---|
| 105 | // eventLogger.Close();
|
---|
[729] | 106 | }
|
---|
[718] | 107 | }
|
---|
| 108 | }
|
---|