DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
EventSourceExtensions.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 using System.Collections.Generic;
19 
20 namespace Deveel.Data.Diagnostics {
21  public static class EventSourceExtensions {
22  public static void OnEvent(this IEventSource source, IEvent @event) {
23  source.Context.RegisterEvent(@event);
24  }
25 
26  public static void OnError(this IEventSource source, Exception error) {
27  OnError(source, error, -1);
28  }
29 
30  public static void OnError(this IEventSource source, Exception error, int errorCode) {
31  OnError(source, error, errorCode, ErrorLevel.Error);
32  }
33 
34  public static void OnError(this IEventSource source, Exception error, ErrorLevel level) {
35  OnError(source, error, -1, level);
36  }
37 
38  public static void OnError(this IEventSource source, Exception error, int errorCode, ErrorLevel level) {
39  var errorEvent = new ErrorEvent(error, errorCode, level);
40  source.OnEvent(errorEvent);
41  }
42 
43  public static void OnInformation(this IEventSource source, string message) {
44  source.OnInformation(message, InformationLevel.Information);
45  }
46 
47  public static void OnInformation(this IEventSource source, string message, InformationLevel level) {
48  source.OnEvent(new InformationEvent(message, level));
49  }
50 
51  public static void OnVerbose(this IEventSource source, string message) {
52  source.OnInformation(message, InformationLevel.Verbose);
53  }
54 
55  public static void OnDebug(this IEventSource source, string message) {
56  source.OnInformation(message, InformationLevel.Debug);
57  }
58 
59  public static void OnPerformance(this IEventSource source, string key, object value) {
60  source.OnEvent(new PerformanceEvent(key, value));
61  }
62  }
63 }
static void OnError(this IEventSource source, Exception error, int errorCode, ErrorLevel level)
static void OnDebug(this IEventSource source, string message)
This is an event occurred during the lifetime of a database.
Definition: IEvent.cs:24
static void OnError(this IEventSource source, Exception error, int errorCode)
ErrorLevel
In case of error messages, this enumerates the level of severity of the error.
Definition: ErrorLevel.cs:24
static void OnPerformance(this IEventSource source, string key, object value)
static void OnError(this IEventSource source, Exception error, ErrorLevel level)
static void OnVerbose(this IEventSource source, string message)
static void OnInformation(this IEventSource source, string message)
static void OnError(this IEventSource source, Exception error)
static void OnInformation(this IEventSource source, string message, InformationLevel level)
static void OnEvent(this IEventSource source, IEvent @event)
Represents the origin of system events, providing a mechanism to fill the metadata before dispatching...
Definition: IEventSource.cs:40