Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~cszikszoy/docky/logging |
Merge into: | lp:docky |
Diff against target: |
894 lines 18 files modified
Docky.Services/Docky.Services.csproj (+6/-0) Docky.Services/Docky.Services/DockServices.cs (+7/-1) Docky.Services/Docky.Services/Log.cs (+59/-0) Docky.Services/Docky.Services/LogTSender.cs (+58/-0) Docky.Services/Docky.Services/Logging/ConsoleCrayon.cs (+197/-0) Docky.Services/Docky.Services/Logging/ConsoleLog.cs (+84/-0) Docky.Services/Docky.Services/Logging/LogBase.cs (+81/-0) Docky.Services/Docky.Services/Preferences.cs (+15/-15) Docky.Services/Docky.Services/SystemService.cs (+8/-9) Docky.Services/Makefile.am (+5/-0) Docky.StandardPlugins/RemovableDevices/VolumeProvider.cs (+4/-3) Docky.StandardPlugins/Trash/TrashDockItem.cs (+2/-3) Docky.Zeitgeist/Docky.Zeitgeist.csproj (+6/-0) Docky.Zeitgeist/Makefile.am (+3/-0) Docky.Zeitgeist/Zeitgeist/ZeitgeistProxy.cs (+5/-3) Docky/Docky/Docky.cs (+6/-1) Docky/Docky/Interface/AutohideManager.cs (+4/-1) Docky/gtk-gui/gui.stetic (+1/-1) |
To merge this branch: | bzr merge lp:~cszikszoy/docky/logging |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Smith (community) | Approve | ||
Review via email: mp+13033@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Chris S. (cszikszoy) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Docky.Services/Docky.Services.csproj' |
2 | --- Docky.Services/Docky.Services.csproj 2009-10-07 10:22:01 +0000 |
3 | +++ Docky.Services/Docky.Services.csproj 2009-10-08 01:25:18 +0000 |
4 | @@ -80,9 +80,15 @@ |
5 | <Compile Include="Docky.Services\Preferences.cs" /> |
6 | <Compile Include="Docky.Services\NotificationService.cs" /> |
7 | <Compile Include="Docky.Services\ConnectionStatusChangeEventArgs.cs" /> |
8 | + <Compile Include="Docky.Services\Logging\LogBase.cs" /> |
9 | + <Compile Include="Docky.Services\Logging\ConsoleCrayon.cs" /> |
10 | + <Compile Include="Docky.Services\LogTSender.cs" /> |
11 | + <Compile Include="Docky.Services\Log.cs" /> |
12 | + <Compile Include="Docky.Services\Logging\ConsoleLog.cs" /> |
13 | </ItemGroup> |
14 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
15 | <ItemGroup> |
16 | <Folder Include="Docky.Services\" /> |
17 | + <Folder Include="Docky.Services\Logging\" /> |
18 | </ItemGroup> |
19 | </Project> |
20 | |
21 | === modified file 'Docky.Services/Docky.Services/DockServices.cs' |
22 | --- Docky.Services/Docky.Services/DockServices.cs 2009-09-25 06:14:39 +0000 |
23 | +++ Docky.Services/Docky.Services/DockServices.cs 2009-10-08 01:25:18 +0000 |
24 | @@ -21,7 +21,7 @@ |
25 | { |
26 | |
27 | |
28 | - public static class DockServices |
29 | + public class DockServices |
30 | { |
31 | public static DrawingService Drawing { get; private set; } |
32 | |
33 | @@ -31,12 +31,18 @@ |
34 | |
35 | public static NotificationService Notifications { get; private set; } |
36 | |
37 | + public DockServices () |
38 | + { |
39 | + } |
40 | + |
41 | static DockServices () |
42 | { |
43 | Drawing = new DrawingService (); |
44 | Preferences = new PreferencesService (); |
45 | System = new SystemService (); |
46 | Notifications = new NotificationService (); |
47 | + |
48 | + Log<DockServices>.Info ("Dock services initialized."); |
49 | } |
50 | } |
51 | } |
52 | |
53 | === added file 'Docky.Services/Docky.Services/Log.cs' |
54 | --- Docky.Services/Docky.Services/Log.cs 1970-01-01 00:00:00 +0000 |
55 | +++ Docky.Services/Docky.Services/Log.cs 2009-10-08 01:25:18 +0000 |
56 | @@ -0,0 +1,59 @@ |
57 | +// |
58 | +// Copyright (C) 2009 Jason Smith |
59 | +// |
60 | +// This program is free software: you can redistribute it and/or modify |
61 | +// it under the terms of the GNU General Public License as published by |
62 | +// the Free Software Foundation, either version 3 of the License, or |
63 | +// (at your option) any later version. |
64 | +// |
65 | +// This program is distributed in the hope that it will be useful, |
66 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
67 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
68 | +// GNU General Public License for more details. |
69 | +// |
70 | +// You should have received a copy of the GNU General Public License |
71 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
72 | +// |
73 | + |
74 | +using System; |
75 | + |
76 | +namespace Docky.Services |
77 | +{ |
78 | + |
79 | + public enum LogLevel { |
80 | + Debug, |
81 | + Info, |
82 | + Warn, |
83 | + Error, |
84 | + Fatal, |
85 | + } |
86 | + |
87 | + public class Log : Logging.LogBase |
88 | + { |
89 | + |
90 | + public static void Debug (string msg, params object [] args) |
91 | + { |
92 | + Write (LogLevel.Debug, msg, args); |
93 | + } |
94 | + |
95 | + public static void Info (string msg, params object [] args) |
96 | + { |
97 | + Write (LogLevel.Info, msg, args); |
98 | + } |
99 | + |
100 | + public static void Warn (string msg, params object [] args) |
101 | + { |
102 | + Write (LogLevel.Warn, msg, args); |
103 | + } |
104 | + |
105 | + public static void Error (string msg, params object [] args) |
106 | + { |
107 | + Write (LogLevel.Error, msg, args); |
108 | + } |
109 | + |
110 | + public static void Fatal (string msg, params object [] args) |
111 | + { |
112 | + Write (LogLevel.Fatal, msg, args); |
113 | + } |
114 | + } |
115 | +} |
116 | |
117 | === added file 'Docky.Services/Docky.Services/LogTSender.cs' |
118 | --- Docky.Services/Docky.Services/LogTSender.cs 1970-01-01 00:00:00 +0000 |
119 | +++ Docky.Services/Docky.Services/LogTSender.cs 2009-10-08 01:25:18 +0000 |
120 | @@ -0,0 +1,58 @@ |
121 | +// |
122 | +// Copyright (C) 2009 Jason Smith |
123 | +// |
124 | +// This program is free software: you can redistribute it and/or modify |
125 | +// it under the terms of the GNU General Public License as published by |
126 | +// the Free Software Foundation, either version 3 of the License, or |
127 | +// (at your option) any later version. |
128 | +// |
129 | +// This program is distributed in the hope that it will be useful, |
130 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
131 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
132 | +// GNU General Public License for more details. |
133 | +// |
134 | +// You should have received a copy of the GNU General Public License |
135 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
136 | +// |
137 | + |
138 | +using System; |
139 | + |
140 | +namespace Docky.Services |
141 | +{ |
142 | + |
143 | + public class Log<TSender> : Logging.LogBase |
144 | + { |
145 | + |
146 | + const string SenderFormat = "[{0}] {1}"; |
147 | + |
148 | + static string AddSender (string message) |
149 | + { |
150 | + return string.Format (SenderFormat, typeof (TSender).Name, message); |
151 | + } |
152 | + |
153 | + public static void Debug (string msg, params object [] args) |
154 | + { |
155 | + Write (LogLevel.Debug, AddSender (msg), args); |
156 | + } |
157 | + |
158 | + public static void Info (string msg, params object [] args) |
159 | + { |
160 | + Write (LogLevel.Info, AddSender (msg), args); |
161 | + } |
162 | + |
163 | + public static void Warn (string msg, params object [] args) |
164 | + { |
165 | + Write (LogLevel.Warn, AddSender (msg), args); |
166 | + } |
167 | + |
168 | + public static void Error (string msg, params object [] args) |
169 | + { |
170 | + Write (LogLevel.Error, AddSender (msg), args); |
171 | + } |
172 | + |
173 | + public static void Fatal (string msg, params object [] args) |
174 | + { |
175 | + Write (LogLevel.Fatal, AddSender (msg), args); |
176 | + } |
177 | + } |
178 | +} |
179 | |
180 | === added directory 'Docky.Services/Docky.Services/Logging' |
181 | === added file 'Docky.Services/Docky.Services/Logging/ConsoleCrayon.cs' |
182 | --- Docky.Services/Docky.Services/Logging/ConsoleCrayon.cs 1970-01-01 00:00:00 +0000 |
183 | +++ Docky.Services/Docky.Services/Logging/ConsoleCrayon.cs 2009-10-08 01:25:18 +0000 |
184 | @@ -0,0 +1,197 @@ |
185 | +// ConsoleCrayon.cs |
186 | +// |
187 | +// Author: |
188 | +// Aaron Bockover <abockover@novell.com> |
189 | +// |
190 | +// Copyright (C) 2008 Novell, Inc. |
191 | +// |
192 | +// Permission is hereby granted, free of charge, to any person obtaining |
193 | +// a copy of this software and associated documentation files (the |
194 | +// "Software"), to deal in the Software without restriction, including |
195 | +// without limitation the rights to use, copy, modify, merge, publish, |
196 | +// distribute, sublicense, and/or sell copies of the Software, and to |
197 | +// permit persons to whom the Software is furnished to do so, subject to |
198 | +// the following conditions: |
199 | +// |
200 | +// The above copyright notice and this permission notice shall be |
201 | +// included in all copies or substantial portions of the Software. |
202 | +// |
203 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
204 | +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
205 | +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
206 | +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
207 | +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
208 | +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
209 | +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
210 | +// |
211 | + |
212 | +using System; |
213 | + |
214 | +namespace Docky.Services.Logging |
215 | +{ |
216 | + internal static class ConsoleCrayon |
217 | + { |
218 | + |
219 | +#region Public API |
220 | + |
221 | + private static ConsoleColor foreground_color; |
222 | + public static ConsoleColor ForegroundColor { |
223 | + get { return foreground_color; } |
224 | + set { |
225 | + foreground_color = value; |
226 | + SetColor (foreground_color, true); |
227 | + } |
228 | + } |
229 | + |
230 | + private static ConsoleColor background_color; |
231 | + public static ConsoleColor BackgroundColor { |
232 | + get { return background_color; } |
233 | + set { |
234 | + background_color = value; |
235 | + SetColor (background_color, false); |
236 | + } |
237 | + } |
238 | + |
239 | + public static void ResetColor () |
240 | + { |
241 | + if (XtermColors) { |
242 | + Console.Write (GetAnsiResetControlCode ()); |
243 | + } else if (Environment.OSVersion.Platform != PlatformID.Unix && |
244 | + !RuntimeIsMono) { |
245 | + Console.ResetColor (); |
246 | + } |
247 | + } |
248 | + |
249 | + private static void SetColor (ConsoleColor color, bool isForeground) |
250 | + { |
251 | + if (color < ConsoleColor.Black || color > ConsoleColor.White) { |
252 | + throw new ArgumentOutOfRangeException ("color", |
253 | + "Not a ConsoleColor value."); |
254 | + } |
255 | + |
256 | + if (XtermColors) { |
257 | + Console.Write (GetAnsiColorControlCode (color, isForeground)); |
258 | + } else if (Environment.OSVersion.Platform != PlatformID.Unix && |
259 | + !RuntimeIsMono) { |
260 | + if (isForeground) { |
261 | + Console.ForegroundColor = color; |
262 | + } else { |
263 | + Console.BackgroundColor = color; |
264 | + } |
265 | + } |
266 | + } |
267 | + |
268 | +#endregion |
269 | + |
270 | +#region Ansi/VT Code Calculation |
271 | + |
272 | + // Modified from Mono's System.TermInfoDriver |
273 | + // License: MIT/X11 |
274 | + // Authors: Gonzalo Paniagua Javier <gonzalo@ximian.com> |
275 | + // (C) 2005-2006 Novell, Inc <http://www.novell.com> |
276 | + |
277 | + private static int TranslateColor (ConsoleColor desired, out bool light) |
278 | + { |
279 | + light = false; |
280 | + switch (desired) { |
281 | + // Dark colors |
282 | + case ConsoleColor.Black: return 0; |
283 | + case ConsoleColor.DarkRed: return 1; |
284 | + case ConsoleColor.DarkGreen: return 2; |
285 | + case ConsoleColor.DarkYellow: return 3; |
286 | + case ConsoleColor.DarkBlue: return 4; |
287 | + case ConsoleColor.DarkMagenta: return 5; |
288 | + case ConsoleColor.DarkCyan: return 6; |
289 | + case ConsoleColor.Gray: return 7; |
290 | + |
291 | + // Light colors |
292 | + case ConsoleColor.DarkGray: light = true; return 0; |
293 | + case ConsoleColor.Red: light = true; return 1; |
294 | + case ConsoleColor.Green: light = true; return 2; |
295 | + case ConsoleColor.Yellow: light = true; return 3; |
296 | + case ConsoleColor.Blue: light = true; return 4; |
297 | + case ConsoleColor.Magenta: light = true; return 5; |
298 | + case ConsoleColor.Cyan: light = true; return 6; |
299 | + case ConsoleColor.White: default: light = true; return 7; |
300 | + } |
301 | + } |
302 | + |
303 | + private static string GetAnsiColorControlCode (ConsoleColor color, bool isForeground) |
304 | + { |
305 | + // lighter fg colours are 90 -> 97 rather than 30 -> 37 |
306 | + // lighter bg colours are 100 -> 107 rather than 40 -> 47 |
307 | + bool light; |
308 | + int code = TranslateColor (color, out light) + (isForeground ? 30 : 40) + (light ? 60 : 0); |
309 | + return String.Format ("\x001b[{0}m", code); |
310 | + } |
311 | + |
312 | + private static string GetAnsiResetControlCode () |
313 | + { |
314 | + return "\x001b[0m"; |
315 | + } |
316 | + |
317 | +#endregion |
318 | + |
319 | +#region xterm Detection |
320 | + |
321 | + private static bool? xterm_colors = null; |
322 | + public static bool XtermColors { |
323 | + get { |
324 | + if (xterm_colors == null) { |
325 | + DetectXtermColors (); |
326 | + } |
327 | + |
328 | + return xterm_colors.Value; |
329 | + } |
330 | + } |
331 | + |
332 | + [System.Runtime.InteropServices.DllImport ("libc", EntryPoint="isatty")] |
333 | + private extern static int _isatty (int fd); |
334 | + |
335 | + private static bool isatty (int fd) |
336 | + { |
337 | + try { |
338 | + return _isatty (fd) == 1; |
339 | + } catch { |
340 | + return false; |
341 | + } |
342 | + } |
343 | + |
344 | + private static void DetectXtermColors () |
345 | + { |
346 | + bool _xterm_colors = false; |
347 | + |
348 | + switch (Environment.GetEnvironmentVariable ("TERM")) { |
349 | + case "xterm": |
350 | + case "rxvt": |
351 | + case "rxvt-unicode": |
352 | + if (Environment.GetEnvironmentVariable ("COLORTERM") != null) { |
353 | + _xterm_colors = true; |
354 | + } |
355 | + break; |
356 | + case "xterm-color": |
357 | + _xterm_colors = true; |
358 | + break; |
359 | + } |
360 | + |
361 | + xterm_colors = _xterm_colors && isatty (1) && isatty (2); |
362 | + } |
363 | + |
364 | +#endregion |
365 | + |
366 | +#region Runtime Detection |
367 | + |
368 | + private static bool? runtime_is_mono; |
369 | + public static bool RuntimeIsMono { |
370 | + get { |
371 | + if (runtime_is_mono == null) { |
372 | + runtime_is_mono = Type.GetType ("System.MonoType") != null; |
373 | + } |
374 | + |
375 | + return runtime_is_mono.Value; |
376 | + } |
377 | + } |
378 | + |
379 | +#endregion |
380 | + } |
381 | +} |
382 | |
383 | === added file 'Docky.Services/Docky.Services/Logging/ConsoleLog.cs' |
384 | --- Docky.Services/Docky.Services/Logging/ConsoleLog.cs 1970-01-01 00:00:00 +0000 |
385 | +++ Docky.Services/Docky.Services/Logging/ConsoleLog.cs 2009-10-08 01:25:18 +0000 |
386 | @@ -0,0 +1,84 @@ |
387 | +// |
388 | +// Copyright (C) 2009 Jason Smith |
389 | +// |
390 | +// This program is free software: you can redistribute it and/or modify |
391 | +// it under the terms of the GNU General Public License as published by |
392 | +// the Free Software Foundation, either version 3 of the License, or |
393 | +// (at your option) any later version. |
394 | +// |
395 | +// This program is distributed in the hope that it will be useful, |
396 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
397 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
398 | +// GNU General Public License for more details. |
399 | +// |
400 | +// You should have received a copy of the GNU General Public License |
401 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
402 | +// |
403 | + |
404 | +using System; |
405 | + |
406 | +namespace Docky.Services.Logging |
407 | +{ |
408 | + |
409 | + |
410 | + internal static class ConsoleLog |
411 | + { |
412 | + /// <value> |
413 | + /// A string to make printing the current time simpler |
414 | + /// </value> |
415 | + const string TimeFormat = "{0:00}:{1:00}:{2:00}.{3:000}"; |
416 | + |
417 | + /// <value> |
418 | + /// A consistent way of printing [Time LogLevel] |
419 | + /// </value> |
420 | + const string LogFormat = "[{0,-5} {1}]"; |
421 | + |
422 | + /// <value> |
423 | + /// the current time using the TimeFormat format. |
424 | + /// </value> |
425 | + static string Time { |
426 | + get { |
427 | + DateTime now = DateTime.Now; |
428 | + return string.Format (TimeFormat, now.Hour, now.Minute, now.Second, now.Millisecond); |
429 | + } |
430 | + } |
431 | + |
432 | + static string FormatLogPrompt (LogLevel level) |
433 | + { |
434 | + string levelString = Enum.GetName (typeof (LogLevel), level); |
435 | + return string.Format (LogFormat, levelString, Time); |
436 | + } |
437 | + |
438 | + static string FormatLogMessage (LogLevel level, string message) |
439 | + { |
440 | + return string.Format ("{0} {1}", FormatLogPrompt (level), message); |
441 | + } |
442 | + |
443 | + public static void Log (LogLevel level, string message) |
444 | + { |
445 | + switch (level) { |
446 | + case LogLevel.Fatal: |
447 | + ConsoleCrayon.BackgroundColor = ConsoleColor.Red; |
448 | + ConsoleCrayon.ForegroundColor = ConsoleColor.White; |
449 | + break; |
450 | + case LogLevel.Error: |
451 | + ConsoleCrayon.ForegroundColor = ConsoleColor.Red; |
452 | + break; |
453 | + case LogLevel.Warn: |
454 | + ConsoleCrayon.ForegroundColor = ConsoleColor.Yellow; |
455 | + break; |
456 | + case LogLevel.Info: |
457 | + ConsoleCrayon.ForegroundColor = ConsoleColor.Blue; |
458 | + break; |
459 | + case LogLevel.Debug: |
460 | + ConsoleCrayon.ForegroundColor = ConsoleColor.Green; |
461 | + break; |
462 | + } |
463 | + Console.Write (FormatLogPrompt (level)); |
464 | + ConsoleCrayon.ResetColor (); |
465 | + |
466 | + Console.Write (" "); |
467 | + Console.WriteLine (message); |
468 | + } |
469 | + } |
470 | +} |
471 | |
472 | === added file 'Docky.Services/Docky.Services/Logging/LogBase.cs' |
473 | --- Docky.Services/Docky.Services/Logging/LogBase.cs 1970-01-01 00:00:00 +0000 |
474 | +++ Docky.Services/Docky.Services/Logging/LogBase.cs 2009-10-08 01:25:19 +0000 |
475 | @@ -0,0 +1,81 @@ |
476 | +// |
477 | +// Copyright (C) 2009 Jason Smith |
478 | +// |
479 | +// This program is free software: you can redistribute it and/or modify |
480 | +// it under the terms of the GNU General Public License as published by |
481 | +// the Free Software Foundation, either version 3 of the License, or |
482 | +// (at your option) any later version. |
483 | +// |
484 | +// This program is distributed in the hope that it will be useful, |
485 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
486 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
487 | +// GNU General Public License for more details. |
488 | +// |
489 | +// You should have received a copy of the GNU General Public License |
490 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
491 | +// |
492 | + |
493 | +using System; |
494 | +using System.Linq; |
495 | +using System.Collections.Generic; |
496 | + |
497 | +namespace Docky.Services.Logging |
498 | +{ |
499 | + |
500 | + public abstract class LogBase |
501 | + { |
502 | + class LogCall |
503 | + { |
504 | + public readonly LogLevel Level; |
505 | + public readonly string Message; |
506 | + |
507 | + public LogCall (LogLevel level, string message) |
508 | + { |
509 | + Level = level; |
510 | + Message = message; |
511 | + } |
512 | + } |
513 | + |
514 | + public static LogLevel DisplayLevel { get; set; } |
515 | + |
516 | + static bool Writing { get; set; } |
517 | + static ICollection<LogCall> PendingLogCalls { get; set; } |
518 | + |
519 | + static LogBase () |
520 | + { |
521 | + Writing = false; |
522 | + PendingLogCalls = new LinkedList<LogCall> (); |
523 | + } |
524 | + |
525 | + public static void Write (LogLevel level, string msg, params object[] args) |
526 | + { |
527 | + if (level < DisplayLevel) return; |
528 | + |
529 | + msg = string.Format (msg, args); |
530 | + if (Writing) { |
531 | + // In the process of logging, another log call has been made. |
532 | + // We need to avoid the infinite regress this may cause. |
533 | + PendingLogCalls.Add (new LogCall (level, msg)); |
534 | + } else { |
535 | + Writing = true; |
536 | + |
537 | + if (PendingLogCalls.Any ()) { |
538 | + // Flush delayed log calls. |
539 | + // First, swap PendingLogCalls with an empty collection so it |
540 | + // is not modified while we enumerate. |
541 | + IEnumerable<LogCall> calls = PendingLogCalls; |
542 | + PendingLogCalls = new LinkedList<LogCall> (); |
543 | + |
544 | + // Log all pending calls. |
545 | + foreach (LogCall call in calls) |
546 | + ConsoleLog.Log (call.Level, call.Message); |
547 | + } |
548 | + |
549 | + // Log message. |
550 | + ConsoleLog.Log (level, msg); |
551 | + |
552 | + Writing = false; |
553 | + } |
554 | + } |
555 | + } |
556 | +} |
557 | |
558 | === modified file 'Docky.Services/Docky.Services/Preferences.cs' |
559 | --- Docky.Services/Docky.Services/Preferences.cs 2009-10-07 03:35:14 +0000 |
560 | +++ Docky.Services/Docky.Services/Preferences.cs 2009-10-08 01:25:18 +0000 |
561 | @@ -44,12 +44,12 @@ |
562 | try { |
563 | result = client.Get (AbsolutePathForKey (key, GConfPrefix)); |
564 | } catch (GConf.NoSuchKeyException e) { |
565 | - Console.Error.WriteLine (e.Message); |
566 | + Log.Debug ("Key {0} does not exist, creating.", key); |
567 | Set<T> (key, def); |
568 | return def; |
569 | } catch (Exception e) { |
570 | - Console.Error.WriteLine (e.Message); |
571 | - Console.Error.WriteLine (e.StackTrace); |
572 | + Log.Error ("Failed to get gconf value for {0} : '{1}'", key, e.Message); |
573 | + Log.Info (e.StackTrace); |
574 | return def; |
575 | } |
576 | |
577 | @@ -65,8 +65,8 @@ |
578 | try { |
579 | client.Set (AbsolutePathForKey (key, GConfPrefix), val); |
580 | } catch (Exception e) { |
581 | - Console.Error.WriteLine ("Encountered error setting GConf key {0}: {1}", key, e.Message); |
582 | - Console.Error.WriteLine (e.StackTrace); |
583 | + Log.Error ("Encountered error setting GConf key {0}: '{1}'", key, e.Message); |
584 | + Log.Info (e.StackTrace); |
585 | success = false; |
586 | } |
587 | return success; |
588 | @@ -83,11 +83,11 @@ |
589 | |
590 | #region IPreferences - secure, based on Gnome Keyring |
591 | |
592 | - //readonly string ErrorSavingMessage = Catalog.GetString ("Error saving {0}"); |
593 | - //readonly string KeyNotFoundMessage = Catalog.GetString ("Key \"{0}\" not found in keyring"); |
594 | - //readonly string KeyringUnavailableMessage = Catalog.GetString ("gnome-keyring-daemon could not be reached!"); |
595 | + readonly string ErrorSavingMessage = "Error saving {0} : '{0}'"; |
596 | + readonly string KeyNotFoundMessage = "Key \"{0}\" not found in keyring"; |
597 | + readonly string KeyringUnavailableMessage = "gnome-keyring-daemon could not be reached!"; |
598 | |
599 | - const string DefaultRootPath = "gnome-do"; |
600 | + const string DefaultRootPath = "docky"; |
601 | |
602 | public bool SetSecure<T> (string key, T val) |
603 | { |
604 | @@ -97,7 +97,7 @@ |
605 | Hashtable keyData; |
606 | |
607 | if (!Ring.Available) { |
608 | - //Log.Error (KeyringUnavailableMessage); |
609 | + Log.Error (KeyringUnavailableMessage); |
610 | return false; |
611 | } |
612 | |
613 | @@ -106,9 +106,9 @@ |
614 | |
615 | try { |
616 | Ring.CreateItem (Ring.GetDefaultKeyring (), ItemType.GenericSecret, AbsolutePathForKey (key, DefaultRootPath), keyData, val.ToString (), true); |
617 | - } catch /*(KeyringException e)*/ { |
618 | - //Log.Error (ErrorSavingMessage, key, e.Message); |
619 | - //Log.Debug (e.StackTrace); |
620 | + } catch (KeyringException e) { |
621 | + Log.Error (ErrorSavingMessage, key, e.Message); |
622 | + Log.Info (e.StackTrace); |
623 | return false; |
624 | } |
625 | |
626 | @@ -120,7 +120,7 @@ |
627 | Hashtable keyData; |
628 | |
629 | if (!Ring.Available) { |
630 | - //Log.Error (KeyringUnavailableMessage); |
631 | + Log.Error (KeyringUnavailableMessage); |
632 | return def; |
633 | } |
634 | |
635 | @@ -135,7 +135,7 @@ |
636 | return (T) Convert.ChangeType (secureValue, typeof (T)); |
637 | } |
638 | } catch (KeyringException) { |
639 | - //Log.Debug (KeyNotFoundMessage, AbsolutePathForKey (key)); |
640 | + Log.Error (KeyNotFoundMessage, AbsolutePathForKey (key, DefaultRootPath)); |
641 | } |
642 | |
643 | return def; |
644 | |
645 | === modified file 'Docky.Services/Docky.Services/SystemService.cs' |
646 | --- Docky.Services/Docky.Services/SystemService.cs 2009-10-07 17:48:01 +0000 |
647 | +++ Docky.Services/Docky.Services/SystemService.cs 2009-10-08 01:25:18 +0000 |
648 | @@ -43,11 +43,10 @@ |
649 | network.StateChanged += OnConnectionStatusChanged; |
650 | SetConnected (); |
651 | } |
652 | - } catch /*(Exception e)*/ { |
653 | + } catch (Exception e) { |
654 | // if something bad happened, log the error and assume we are connected |
655 | - // FIXME: use proper logging |
656 | - //Log<NetworkService>.Error ("Could not initialize Network Manager dbus: {0}", e.Message); |
657 | - //Log<NetworkService>.Debug (e.StackTrace); |
658 | + Log<SystemService>.Error ("Could not initialize Network Manager dbus: '{0}'", e.Message); |
659 | + Log<SystemService>.Info (e.StackTrace); |
660 | NetworkConnected = true; |
661 | } |
662 | } |
663 | @@ -149,16 +148,16 @@ |
664 | devicekit = Bus.System.GetObject<IDeviceKitPower> (DeviceKitPowerName, new ObjectPath (DeviceKitPowerPath)); |
665 | devicekit.OnChanged += DeviceKitOnChanged; |
666 | on_battery = (bool) devicekit.Get (DeviceKitPowerName, "on-battery"); |
667 | - //Log<SystemService>.Debug ("Using org.freedesktop.DeviceKit.Power for battery information"); |
668 | + Log<SystemService>.Debug ("Using org.freedesktop.DeviceKit.Power for battery information"); |
669 | } else if (Bus.Session.NameHasOwner (PowerManagementName)) { |
670 | power = Bus.Session.GetObject<IPowerManagement> (PowerManagementName, new ObjectPath (PowerManagementPath)); |
671 | power.OnBatteryChanged += PowerOnBatteryChanged; |
672 | on_battery = power.GetOnBattery (); |
673 | - //Log<SystemService>.Debug ("Using org.freedesktop.PowerManager for battery information"); |
674 | + Log<SystemService>.Debug ("Using org.freedesktop.PowerManager for battery information"); |
675 | } |
676 | - } catch /*(Exception e)*/ { |
677 | - //Log<SystemService>.Error ("Could not initialize dbus: {0}", e.Message); |
678 | - //Log<SystemService>.Debug (e.StackTrace); |
679 | + } catch (Exception e) { |
680 | + Log<SystemService>.Error ("Could not initialize power manager dbus: '{0}'", e.Message); |
681 | + Log<SystemService>.Info (e.StackTrace); |
682 | } |
683 | } |
684 | |
685 | |
686 | === modified file 'Docky.Services/Makefile.am' |
687 | --- Docky.Services/Makefile.am 2009-10-07 10:22:01 +0000 |
688 | +++ Docky.Services/Makefile.am 2009-10-08 01:25:18 +0000 |
689 | @@ -7,6 +7,11 @@ |
690 | PKG_CONFIG_FILES = docky.services.pc |
691 | |
692 | FILES = \ |
693 | + Docky.Services/Logging/ConsoleCrayon.cs \ |
694 | + Docky.Services/Logging/LogBase.cs \ |
695 | + Docky.Services/Logging/ConsoleLog.cs \ |
696 | + Docky.Services/Log.cs \ |
697 | + Docky.Services/LogTSender.cs \ |
698 | Docky.Services/ConnectionStatusChangeEventArgs.cs \ |
699 | Docky.Services/IPreferences.cs \ |
700 | Docky.Services/PreferencesService.cs \ |
701 | |
702 | === modified file 'Docky.StandardPlugins/RemovableDevices/VolumeProvider.cs' |
703 | --- Docky.StandardPlugins/RemovableDevices/VolumeProvider.cs 2009-10-07 00:49:24 +0000 |
704 | +++ Docky.StandardPlugins/RemovableDevices/VolumeProvider.cs 2009-10-08 01:25:19 +0000 |
705 | @@ -22,6 +22,7 @@ |
706 | using Gnome.Vfs; |
707 | |
708 | using Docky.Items; |
709 | +using Docky.Services; |
710 | |
711 | namespace RemovableDevices |
712 | { |
713 | @@ -61,6 +62,7 @@ |
714 | |
715 | public VolumeProvider () |
716 | { |
717 | + |
718 | Computer = new ComputerItem (); |
719 | |
720 | // initialize VFS in case it isn't already |
721 | @@ -73,7 +75,6 @@ |
722 | |
723 | foreach (Volume v in Monitor.MountedVolumes) { |
724 | if (v.IsUserVisible) { |
725 | - // Console.WriteLine ("adding {0}", v.DisplayName); |
726 | Volumes.Add ( new VolumeItem (v)); |
727 | } |
728 | } |
729 | @@ -85,7 +86,7 @@ |
730 | void HandleVolumeUnmounted(object o, VolumeUnmountedArgs args) |
731 | { |
732 | if (Volumes.Any ( d => d.VfsVolume == args.Volume)) { |
733 | - // Console.WriteLine ("Removing {0}", args.Volume.DisplayName); |
734 | + Log<VolumeProvider>.Info ("{0} unmounted.", args.Volume.DisplayName); |
735 | VolumeItem volToRemove = Volumes.First ( d => d.VfsVolume == args.Volume); |
736 | Volumes.Remove (volToRemove); |
737 | OnItemsChanged (null, (volToRemove as AbstractDockItem).AsSingle ()); |
738 | @@ -95,7 +96,7 @@ |
739 | |
740 | void HandleVolumeMounted(object o, VolumeMountedArgs args) |
741 | { |
742 | - // Console.WriteLine ("Adding {0}", args.Volume.DisplayName); |
743 | + Log<VolumeProvider>.Info ("{0} mounted.", args.Volume.DisplayName); |
744 | VolumeItem newVol = new VolumeItem (args.Volume); |
745 | Volumes.Add (newVol); |
746 | OnItemsChanged ((newVol as AbstractDockItem).AsSingle (), null); |
747 | |
748 | === modified file 'Docky.StandardPlugins/Trash/TrashDockItem.cs' |
749 | --- Docky.StandardPlugins/Trash/TrashDockItem.cs 2009-10-07 03:35:14 +0000 |
750 | +++ Docky.StandardPlugins/Trash/TrashDockItem.cs 2009-10-08 01:25:19 +0000 |
751 | @@ -149,9 +149,8 @@ |
752 | { |
753 | try { |
754 | DockServices.System.Execute (string.Format ("gvfs-trash \"{0}\"", item)); |
755 | - } catch /*(Exception e)*/ { |
756 | -// Log.Error (e.Message); |
757 | -// Log.Error ("Could not move {0} to trash", item); |
758 | + } catch (Exception e) { |
759 | + Log<TrashDockItem>.Error ("Could not move {0} to trash: '{1}'", item, e.Message); |
760 | return false; |
761 | } |
762 | |
763 | |
764 | === modified file 'Docky.Zeitgeist/Docky.Zeitgeist.csproj' |
765 | --- Docky.Zeitgeist/Docky.Zeitgeist.csproj 2009-10-04 01:02:32 +0000 |
766 | +++ Docky.Zeitgeist/Docky.Zeitgeist.csproj 2009-10-08 01:25:19 +0000 |
767 | @@ -49,4 +49,10 @@ |
768 | <Compile Include="Zeitgeist\ZeitgeistFilter.cs" /> |
769 | </ItemGroup> |
770 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
771 | + <ItemGroup> |
772 | + <ProjectReference Include="..\Docky.Services\Docky.Services.csproj"> |
773 | + <Project>{8A6E0EDD-6443-4F99-9EAC-D9CC906F080D}</Project> |
774 | + <Name>Docky.Services</Name> |
775 | + </ProjectReference> |
776 | + </ItemGroup> |
777 | </Project> |
778 | \ No newline at end of file |
779 | |
780 | === modified file 'Docky.Zeitgeist/Makefile.am' |
781 | --- Docky.Zeitgeist/Makefile.am 2009-10-04 01:02:32 +0000 |
782 | +++ Docky.Zeitgeist/Makefile.am 2009-10-08 01:25:19 +0000 |
783 | @@ -9,6 +9,9 @@ |
784 | Zeitgeist/ZeitgeistFilter.cs \ |
785 | Zeitgeist/ZeitgeistProxy.cs |
786 | |
787 | +PROJECT_REFERENCES = \ |
788 | + Docky.Services |
789 | + |
790 | REFERENCES = \ |
791 | System \ |
792 | System.Core \ |
793 | |
794 | === modified file 'Docky.Zeitgeist/Zeitgeist/ZeitgeistProxy.cs' |
795 | --- Docky.Zeitgeist/Zeitgeist/ZeitgeistProxy.cs 2009-10-07 18:28:20 +0000 |
796 | +++ Docky.Zeitgeist/Zeitgeist/ZeitgeistProxy.cs 2009-10-08 01:25:19 +0000 |
797 | @@ -24,6 +24,8 @@ |
798 | using NDesk.DBus; |
799 | using org.freedesktop.DBus; |
800 | |
801 | +using Docky.Services; |
802 | + |
803 | namespace Docky.Zeitgeist |
804 | { |
805 | |
806 | @@ -65,8 +67,7 @@ |
807 | if (reply == StartReply.AlreadyRunning || reply == StartReply.Success) |
808 | zeitgeist = Bus.Session.GetObject<IZeitgeistDaemon> (BusName, new ObjectPath (PathName)); |
809 | } catch (Exception e) { |
810 | - Console.Error.WriteLine (e.Message); |
811 | - Console.Error.WriteLine ("Failed to connect to zeitgeist bus"); |
812 | + Log<ZeitgeistProxy>.Error ("Failed to connect to zeitgeist bus : '{0}'", e.Message); |
813 | } |
814 | } |
815 | |
816 | @@ -95,7 +96,8 @@ |
817 | results = zeitgeist.FindEvents (startTime, stopTime, maxResults, ascending, |
818 | mode, filters.Select (f => f.ToDBusFilter ()).ToArray ()); |
819 | } catch (Exception e) { |
820 | - Console.WriteLine (e.Message); |
821 | + Log<ZeitgeistProxy>.Error ("Failed to find Zeitgeist events: '{0}'", e.Message); |
822 | + Log<ZeitgeistProxy>.Info (e.StackTrace); |
823 | yield break; |
824 | } |
825 | |
826 | |
827 | === modified file 'Docky/Docky/Docky.cs' |
828 | --- Docky/Docky/Docky.cs 2009-10-06 21:16:26 +0000 |
829 | +++ Docky/Docky/Docky.cs 2009-10-08 01:25:18 +0000 |
830 | @@ -28,6 +28,7 @@ |
831 | using Gtk; |
832 | |
833 | using Docky.Windowing; |
834 | +using Docky.Services; |
835 | |
836 | namespace Docky |
837 | { |
838 | @@ -71,6 +72,9 @@ |
839 | PluginManager.Initialize (); |
840 | Controller.Initialize (); |
841 | |
842 | + //FIXME: parse args to set log level |
843 | + Log.DisplayLevel = LogLevel.Debug; |
844 | + |
845 | Gdk.Threads.Enter (); |
846 | Gtk.Application.Run (); |
847 | Gdk.Threads.Leave (); |
848 | @@ -89,7 +93,8 @@ |
849 | about.Comments = "Docky. Simply Powerful."; |
850 | about.Authors = new[] { |
851 | "Jason Smith", |
852 | - "Robert Dyer" |
853 | + "Robert Dyer", |
854 | + "Chris Szikszoy" |
855 | }; |
856 | |
857 | about.ShowAll (); |
858 | |
859 | === modified file 'Docky/Docky/Interface/AutohideManager.cs' |
860 | --- Docky/Docky/Interface/AutohideManager.cs 2009-09-23 04:38:35 +0000 |
861 | +++ Docky/Docky/Interface/AutohideManager.cs 2009-10-08 01:25:18 +0000 |
862 | @@ -26,6 +26,8 @@ |
863 | using Gtk; |
864 | using Wnck; |
865 | |
866 | +using Docky.Services; |
867 | + |
868 | namespace Docky.Interface |
869 | { |
870 | |
871 | @@ -193,7 +195,8 @@ |
872 | w.Pid != pid && |
873 | w.EasyGeometry ().IntersectsWith (adjustedDockArea)); |
874 | } catch (Exception e) { |
875 | - Console.WriteLine (e.Message); |
876 | + Log<AutohideManager>.Error ("Failed to update window intersect: '{0}'", e.Message); |
877 | + Log<AutohideManager>.Info (e.StackTrace); |
878 | } |
879 | |
880 | if (WindowIntersectingOther != intersect) { |
881 | |
882 | === modified file 'Docky/gtk-gui/gui.stetic' |
883 | --- Docky/gtk-gui/gui.stetic 2009-10-06 22:36:51 +0000 |
884 | +++ Docky/gtk-gui/gui.stetic 2009-10-08 01:25:18 +0000 |
885 | @@ -10,8 +10,8 @@ |
886 | <widget-library name="../../Docky.Services/bin/Debug/Docky.Services.dll" /> |
887 | <widget-library name="../../Docky.Items/bin/Debug/Docky.Items.dll" /> |
888 | <widget-library name="../../Docky.Windowing/bin/Debug/Docky.Windowing.dll" /> |
889 | + <widget-library name="../../Docky.StandardPlugins/bin/Debug/Docky.StandardPlugins.dll" /> |
890 | <widget-library name="../bin/Debug/Docky.exe" internal="true" /> |
891 | - <widget-library name="../../Docky.StandardPlugins/bin/Debug/Docky.StandardPlugins.dll" /> |
892 | </import> |
893 | <widget class="Gtk.Bin" id="Docky.Interface.DockPreferences" design-size="368 331"> |
894 | <property name="MemberName" /> |
add logging service and clean up all Console.WriteLines