title: Proper way to extend class/method functionality - using NLog as example
body: <p>I'm using the NLog .NET logging library here as an example; my question isn't specific to NLog.</p>
  
  <p>Typical NLog logging looks like this:</p>
  
  <pre><code>private static Logger log = LogManager.GetLogger("logger_name");
  log.Info("Some log message");
  </code></pre>
  
  <p>I want to add functionality to the Info() method.  Perhaps I want some timestamp added to the log message.</p>
  
  <p>The way I've accomplished is absolutely horrendous and just stinks of code smell.</p>
  
  <p>I created a helper class which holds a <code>Logger</code> instance, implements it's own (but named the same) <code>GetLogger()</code> and <code>Info()</code> methods (ugh, just terrible), and then includes some custom functionality in <code>Info()</code>.</p>
  
  <pre><code>public static class NLogLogManagerHelper // Can't derive from LogManager because it's sealed
  {
      public static string _loggerName;
      public static NLog.Logger _log;
  
      public static NLog.Logger GetLogger(string loggerName)
      {
          _loggerName = loggerName;
          _log = LogManager.GetLogger(loggerName);
          return _log;
      }
  
      public static void Info(string message)
      {
          var eventInfo = new LogEventInfo(LogLevel.Info, _loggerName, message);
          // Add some custom functionality
          eventInfo.Properties["mytimestamp"] = Time.ConvertUtcToEst(DateTime.UtcNow);
          _log.Log(eventInfo);
      }
  }
  </code></pre>
  
  <p>I'm not even sure that taking the approach of making a helper and wrapping a Logger is the right approach.</p>
  
  <p>This "works" but is stinky as heck.  One big stink is that it's NLog's <code>Logger</code> class that has the <code>Info()</code> methods, so I could create a <code>MyLogger</code> which inherits from <code>Logger</code>, but then I can't implement <code>Info()</code> because it's not overridable.  Another stink is that since I've duplicated the Info() method I don't have access to any of it's overloads.  I'd like to know the proper way to approach this problem, whether it's an OO approach, or a design pattern, or whatever.</p>