diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f8ee330..56877313 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,11 @@ All notable changes to this project will be documented in this file. ## [Unreleased] ### Added -* Added SetupDependsOnAttribute, which allows you to define ConfigErrors/PostLoad dependencies between Dec classes. This is a prototype and will probably change in the future. -* Added a general-purpose stable dag evaluator, which is exposed mostly because it's often convenient. -* Added Recorder.InputContext, which gives contextual diagnostic information useful for reporting Recorder issues. -* Added the ability to reference class objects contained within Decs. Right now the path generation works only for members, lists, and arrays; this will probably be improved later. +* SetupDependsOnAttribute, which allows you to define ConfigErrors/PostLoad dependencies between Dec classes. This is a prototype and will probably change in the future. +* A general-purpose stable dag evaluator, which is exposed mostly because it's often convenient. +* Recorder.InputContext, which gives contextual diagnostic information useful for reporting Recorder issues. +* The ability to reference class objects contained within Decs. Right now the path generation works only for members, lists, and arrays; this will probably be improved later. +* Debug-log functions to Context and Recorder, making it easier to report issues. ### Breaking * Dec doesn't guarantee what order Decs are initialized in, and it still doesn't . . . but it was *pretty consistent*, and boy, did the above change seriously scramble the order they tend to get initialized in! If you have load dependencies, even if you don't realize that you do, don't be surprised if stuff breaks. Future versions of Dec might include a Dev Mode that intentionally randomizes load order (within the bounds of dependencies) to help catch these issues. diff --git a/src/Context.cs b/src/Context.cs index b4bfb1f2..f4e7e4c9 100644 --- a/src/Context.cs +++ b/src/Context.cs @@ -21,11 +21,38 @@ internal Context(string filename = null, System.Xml.Linq.XElement element = null this.path = path; } + /// + /// Returns the best guess at the path of this Record query. + /// public string PathString() { return path?.Serialize() ?? "[unknown]"; } + /// + /// Post a proper Context-decorated message to the info log. + /// + public void Inf(string message) + { + Dbg.Inf($"{this}: {message}"); + } + + /// + /// Post a proper Context-decorated message to the warning log. + /// + public void Wrn(string message) + { + Dbg.Wrn($"{this}: {message}"); + } + + /// + /// Post a proper Context-decorated message to the error log. + /// + public void Err(string message) + { + Dbg.Err($"{this}: {message}"); + } + public override string ToString() { if (this.element != null) diff --git a/src/Recorder.cs b/src/Recorder.cs index a782df30..5d64366f 100644 --- a/src/Recorder.cs +++ b/src/Recorder.cs @@ -272,6 +272,30 @@ internal IRecordable CreateRecordableFromFactory(Type type, string name, ReaderN /// public abstract Context Context { get; } + /// + /// Post a proper Context-decorated message to the info log. + /// + public void Inf(string message) + { + Context.Inf(message); + } + + /// + /// Post a proper Context-decorated message to the warning log. + /// + public void Wrn(string message) + { + Context.Wrn(message); + } + + /// + /// Post a proper Context-decorated message to the error log. + /// + public void Err(string message) + { + Context.Err(message); + } + /// /// Serialize or deserialize a member of a class. ///