コード例 #1
0
ファイル: Logger.cs プロジェクト: launchdarkly/dotnet-logging
        /// <summary>
        /// Creates a logger instance derived from this instance.
        /// </summary>
        /// <param name="nameSuffix">will be appended to the current logger's name, separated by a
        /// period, to create the new logger's name</param>
        /// <returns>a new logger instance</returns>
        public Logger SubLogger(string nameSuffix)
        {
            if (nameSuffix is null || nameSuffix == "")
            {
                return(this);
            }
            string subName = _name + "." + nameSuffix;

            return(new Logger(subName, _adapter, _adapter.NewChannel(subName)));
        }
コード例 #2
0
ファイル: Logger.cs プロジェクト: launchdarkly/dotnet-logging
 /// <summary>
 /// Creates a named logger instance using the specified adapter.
 /// </summary>
 /// <remarks>
 /// This method (or the equivalent shortcut <c>adapter.Logger(name)</c>) is called by
 /// library code to acquire a <c>Logger</c> instance that it will write output to.
 /// </remarks>
 /// <param name="adapter">the <see cref="ILogAdapter"/> that defines the actual logging
 /// implementation</param>
 /// <param name="name">the name for this logger</param>
 /// <returns>a new logger instance</returns>
 public static Logger WithAdapter(ILogAdapter adapter, string name)
 {
     return(new Logger(name, adapter, adapter.NewChannel(name)));
 }