2012-08-16 07:30:59 +00:00
|
|
|
|
#region Using Statements
|
2015-04-08 14:50:03 +02:00
|
|
|
|
using ANX.Framework.NonXNA.Development;
|
2012-08-16 07:30:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2015-04-08 14:50:03 +02:00
|
|
|
|
using System.ServiceModel;
|
2012-08-16 07:30:59 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// This file is part of the ANX.Framework created by the
|
|
|
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
|
|
|
// For details see: http://anxframework.codeplex.com/license
|
|
|
|
|
|
|
|
|
|
namespace ANX.Framework.Content.Pipeline
|
|
|
|
|
{
|
2015-04-08 14:50:03 +02:00
|
|
|
|
public abstract class ContentBuildLogger : IContentBuildLogger
|
2012-08-16 07:30:59 +00:00
|
|
|
|
{
|
2012-08-22 10:34:39 +00:00
|
|
|
|
private Stack<string> files = new Stack<string>();
|
|
|
|
|
|
2012-08-16 07:30:59 +00:00
|
|
|
|
protected ContentBuildLogger()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-08 14:50:03 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the base reference path used when reporting errors during the content build process.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual string LoggerRootDirectory
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-16 07:30:59 +00:00
|
|
|
|
public abstract void LogImportantMessage(string message, params Object[] messageArgs);
|
2015-04-08 14:50:03 +02:00
|
|
|
|
|
|
|
|
|
public abstract void LogImportantMessage(string helpLink, ContentIdentity contentIdentity, string message, params Object[] messageArgs);
|
|
|
|
|
|
2012-08-16 07:30:59 +00:00
|
|
|
|
public abstract void LogMessage(string message, params Object[] messageArgs);
|
2015-04-08 14:50:03 +02:00
|
|
|
|
|
2012-08-16 07:30:59 +00:00
|
|
|
|
public abstract void LogWarning(string helpLink, ContentIdentity contentIdentity, string message, params Object[] messageArgs);
|
|
|
|
|
|
2015-04-08 14:50:03 +02:00
|
|
|
|
public virtual void PopFile()
|
2012-08-16 07:30:59 +00:00
|
|
|
|
{
|
2012-08-22 10:34:39 +00:00
|
|
|
|
files.Pop();
|
2012-08-16 07:30:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-08 14:50:03 +02:00
|
|
|
|
public virtual void PushFile(string filename)
|
2012-08-16 07:30:59 +00:00
|
|
|
|
{
|
2012-08-22 10:34:39 +00:00
|
|
|
|
files.Push(filename);
|
2012-08-16 07:30:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-08 14:50:03 +02:00
|
|
|
|
protected string GetCurrentFilename()
|
|
|
|
|
{
|
|
|
|
|
return this.GetCurrentFilename(null);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-16 07:30:59 +00:00
|
|
|
|
protected string GetCurrentFilename(ContentIdentity contentIdentity)
|
|
|
|
|
{
|
2015-04-08 14:50:03 +02:00
|
|
|
|
if (contentIdentity != null && !string.IsNullOrEmpty(contentIdentity.SourceFilename))
|
|
|
|
|
{
|
|
|
|
|
return GetRelativeFilename(contentIdentity.SourceFilename);
|
|
|
|
|
}
|
|
|
|
|
if (this.files.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return GetRelativeFilename(this.files.Peek());
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetRelativeFilename(string filename)
|
|
|
|
|
{
|
|
|
|
|
if (LoggerRootDirectory != null && filename.StartsWith(this.LoggerRootDirectory, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return filename.Substring(this.LoggerRootDirectory.Length);
|
|
|
|
|
}
|
|
|
|
|
return filename;
|
2012-08-16 07:30:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|