Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Client.Common/Logging.cs @ 730

Last change on this file since 730 was 729, checked in by kgrading, 16 years ago

implemented a basic logger according to #335

File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Diagnostics;
6
7namespace HeuristicLab.Hive.Client.Common {
8  public class Logging {     
9    private static Logging instance = null;
10    private EventLog eventLogger = null;
11
12    public static Logging getInstance() {
13      if (instance == null)
14        instance = new Logging();
15      return instance;
16    }
17
18    private Logging() {
19      eventLogger = new EventLog("Hive Client Core");   
20    }
21
22    public void Info(String source, String message) {
23      eventLogger.Source = source;
24      eventLogger.WriteEntry(message);     
25      eventLogger.Close();
26    }
27
28    public void Error(String source, String message) {
29      eventLogger.Source = source;
30      eventLogger.WriteEntry(message, EventLogEntryType.Error);
31      eventLogger.Close();
32    }
33
34    public void Error(String source, String message, Exception e) {
35      eventLogger.Source = source;
36      eventLogger.WriteEntry(message +"\n" + e.ToString(), EventLogEntryType.Error);
37      eventLogger.Close();
38    }
39  }
40}
Note: See TracBrowser for help on using the repository browser.