~ubuntu-branches/ubuntu/precise/gnome-do/precise-backports

« back to all changes in this revision

Viewing changes to Do.Addins/src/Do.Addins/LogBridge.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-10-08 20:35:38 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20081008203538-yty5q4gpfx1ldint
Tags: 0.6.1.0-0ubuntu1
* New upstream release.  FFe is (LP: #279328)
* debian/patches/04_fix_locale_path:
  + Fix the translations path sent to gettext.  Without this, translations
    aren't used by Do.
* debian/gnome-do.gconf-defaults:
  + Don't popup the UI on login; wait for the user to summon Do.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* LogBridge.cs
 
2
 *
 
3
 * GNOME Do is the legal property of its developers. Please refer to the
 
4
 * COPYRIGHT file distributed with this
 
5
 * source distribution.
 
6
 *
 
7
 * This program 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
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
 
 
22
using System;
 
23
using System.Diagnostics;
 
24
 
 
25
namespace Do.Addins
 
26
{
 
27
        /// <summary>
 
28
        /// Provides a way for plugins to offer debugging info the Do log.
 
29
        /// Uses reflection to determine which plugin is requesting a log write.
 
30
        /// </summary>
 
31
        public static class LogBridge
 
32
        {
 
33
                /// <summary>
 
34
                /// Print a Log message with Debug severity.
 
35
                /// </summary>
 
36
                /// <param name="msg">
 
37
                /// A <see cref="System.String"/> containing the message to be printed
 
38
                /// </param>
 
39
                /// <param name="args">
 
40
                /// A <see cref="System.Object"/>  params array with any stacktraces, 
 
41
                /// variables, etc.
 
42
                /// </param>
 
43
                public static void Debug (string msg, params object [] args)
 
44
                {
 
45
                        string message = new StackTrace ().GetFrame (1).GetMethod ().DeclaringType.Namespace 
 
46
                                + ": " + msg;
 
47
                        DebugLogRequested (message, args);
 
48
                }
 
49
                
 
50
                /// <summary>
 
51
                /// Print a Log message with Info severity.
 
52
                /// </summary>
 
53
                /// <param name="msg">
 
54
                /// A <see cref="System.String"/> containing the message to be printed
 
55
                /// </param>
 
56
                /// <param name="args">
 
57
                /// A <see cref="System.Object"/>  params array with any stacktraces, 
 
58
                /// variables, etc.
 
59
                /// </param>
 
60
                public static void Info (string msg, params object [] args)
 
61
                {
 
62
                        string message = new StackTrace ().GetFrame (1).GetMethod ().DeclaringType.Namespace 
 
63
                                + ": " + msg;
 
64
                        InfoLogRequested (message, args);
 
65
                }
 
66
                
 
67
                /// <summary>
 
68
                /// Print a Log message with Warn severity.
 
69
                /// </summary>
 
70
                /// <param name="msg">
 
71
                /// A <see cref="System.String"/> containing the message to be printed
 
72
                /// </param>
 
73
                /// <param name="args">
 
74
                /// A <see cref="System.Object"/>  params array with any stacktraces, 
 
75
                /// variables, etc.
 
76
                /// </param>
 
77
                public static void Warn (string msg, params object [] args)
 
78
                {
 
79
                        string message = new StackTrace ().GetFrame (1).GetMethod ().DeclaringType.Namespace 
 
80
                                + ": " + msg;
 
81
                        WarnLogRequested (message, args);
 
82
                }
 
83
                
 
84
                /// <summary>
 
85
                /// Print a Log message with Error severity.
 
86
                /// </summary>
 
87
                /// <param name="msg">
 
88
                /// A <see cref="System.String"/> containing the message to be printed
 
89
                /// </param>
 
90
                /// <param name="args">
 
91
                /// A <see cref="System.Object"/>  params array with any stacktraces, 
 
92
                /// variables, etc.
 
93
                /// </param>
 
94
                public static void Error (string msg, params object [] args)
 
95
                {
 
96
                        string message = new StackTrace ().GetFrame (1).GetMethod ().DeclaringType.Namespace
 
97
                                + ": " + msg;
 
98
                        ErrorLogRequested (message, args);
 
99
                }
 
100
                
 
101
                /// <summary>
 
102
                /// Print a Log message with Fatal severity.
 
103
                /// </summary>
 
104
                /// <param name="msg">
 
105
                /// A <see cref="System.String"/> containing the message to be printed
 
106
                /// </param>
 
107
                /// <param name="args">
 
108
                /// A <see cref="System.Object"/>  params array with any stacktraces, 
 
109
                /// variables, etc.
 
110
                /// </param>
 
111
                public static void Fatal (string msg, params object [] args)
 
112
                {
 
113
                        string message = new StackTrace ().GetFrame (1).GetMethod ().DeclaringType.Namespace 
 
114
                                + ": " + msg;
 
115
                        FatalLogRequested (message, args);
 
116
                }
 
117
                
 
118
                public static event RequestLogHandler DebugLogRequested;
 
119
                public static event RequestLogHandler InfoLogRequested;
 
120
                public static event RequestLogHandler WarnLogRequested;
 
121
                public static event RequestLogHandler ErrorLogRequested;
 
122
                public static event RequestLogHandler FatalLogRequested;
 
123
 
 
124
                public delegate void RequestLogHandler (string msg, params object [] args);
 
125
        }
 
126
}