Files
Common-VS2019/SacsStandardBase/Base/Utils/LoggingUtils.cs
T
2021-05-05 15:36:28 +01:00

47 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace Sarand.Net.Standard.Base.Utils
{
//=======================================================================
public static class LoggingUtils
{
//-------------------------------------------------------------------
// M e t h o d N a m e
//-------------------------------------------------------------------
/*
[MethodImpl(MethodImplOptions.NoInlining)]
public static string GetMyMethodName ()
{
var st = new StackTrace(new StackFrame(1));
return st.GetFrame(0).GetMethod().Name;
}
*/
//-------------------------------------------------------------------
// L o g g i n g P r e f i x
//-------------------------------------------------------------------
/// <summary>
/// Format logging prefix from class and function names.
/// <para>'&lt;class&gt;.&lt;function&gt;'</para>
/// </summary>
public static String GetFn (this Object obj, String function)
{
return GetFn(obj.GetType(), function);
}
/// <summary>
/// Format logging prefix from class and function names.
/// <para>'&lt;class&gt;.&lt;function&gt;'</para>
/// </summary>
public static String GetFn (this Type type, String function)
{
return type.Name + "." + function;
}
//-------------------------------------------------------------------
}
//=======================================================================
}