Browse Source
To try and figure out why stuff is flashing up on the screen when you open a new tree view node, and then decided to put that off for later ;)pull/4/head
7 changed files with 110 additions and 19 deletions
@ -0,0 +1,67 @@ |
|||||
|
// -----------------------------------------------------------------------
|
||||
|
// <copyright file="LogManager.cs" company="Steven Kirk">
|
||||
|
// Copyright 2014 MIT Licence. See licence.md for more information.
|
||||
|
// </copyright>
|
||||
|
// -----------------------------------------------------------------------
|
||||
|
|
||||
|
namespace Perspex.Diagnostics |
||||
|
{ |
||||
|
using System; |
||||
|
using Perspex.Layout; |
||||
|
using Splat; |
||||
|
|
||||
|
public class LogManager : ILogManager |
||||
|
{ |
||||
|
private static LogManager instance; |
||||
|
|
||||
|
public static LogManager Instance |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (instance == null) |
||||
|
{ |
||||
|
instance = new LogManager(); |
||||
|
} |
||||
|
|
||||
|
return instance; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public ILogger Logger |
||||
|
{ |
||||
|
get; |
||||
|
set; |
||||
|
} |
||||
|
|
||||
|
public bool LogPropertyMessages |
||||
|
{ |
||||
|
get; |
||||
|
set; |
||||
|
} |
||||
|
|
||||
|
public bool LogLayoutMessages |
||||
|
{ |
||||
|
get; |
||||
|
set; |
||||
|
} |
||||
|
|
||||
|
public static void Enable(ILogger logger) |
||||
|
{ |
||||
|
Instance.Logger = logger; |
||||
|
Locator.CurrentMutable.Register(() => Instance, typeof(ILogManager)); |
||||
|
} |
||||
|
|
||||
|
public IFullLogger GetLogger(Type type) |
||||
|
{ |
||||
|
if ((type == typeof(PerspexObject) && LogPropertyMessages) || |
||||
|
(type == typeof(Layoutable) && LogLayoutMessages)) |
||||
|
{ |
||||
|
return new WrappingFullLogger(this.Logger, type); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return new WrappingFullLogger(new NullLogger(), type); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue