Skip to content

Commit 168cece

Browse files
committed
Add extension overloads to eliminate empty array allocations.
1 parent cd42d45 commit 168cece

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

src/NHibernate/Logging.NHibernateLoggerExtensions.cs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,51 +18,101 @@ public static void Fatal(this INHibernateLogger logger, Exception exception, str
1818
logger.Log(InternalLogLevel.Fatal, new InternalLogValues(format, args), exception);
1919
}
2020

21+
public static void Fatal(this INHibernateLogger logger, Exception exception, string format)
22+
{
23+
logger.Log(InternalLogLevel.Fatal, new InternalLogValues(format, null), exception);
24+
}
25+
2126
public static void Fatal(this INHibernateLogger logger, string format, params object[] args)
2227
{
2328
logger.Log(InternalLogLevel.Fatal, new InternalLogValues(format, args), null);
2429
}
2530

31+
public static void Fatal(this INHibernateLogger logger, string format)
32+
{
33+
logger.Log(InternalLogLevel.Fatal, new InternalLogValues(format, null), null);
34+
}
35+
2636
public static void Error(this INHibernateLogger logger, Exception exception, string format, params object[] args)
2737
{
2838
logger.Log(InternalLogLevel.Error, new InternalLogValues(format, args), exception);
2939
}
3040

41+
public static void Error(this INHibernateLogger logger, Exception exception, string format)
42+
{
43+
logger.Log(InternalLogLevel.Error, new InternalLogValues(format, null), exception);
44+
}
45+
3146
public static void Error(this INHibernateLogger logger, string format, params object[] args)
3247
{
3348
logger.Log(InternalLogLevel.Error, new InternalLogValues(format, args), null);
3449
}
3550

51+
public static void Error(this INHibernateLogger logger, string format)
52+
{
53+
logger.Log(InternalLogLevel.Error, new InternalLogValues(format, null), null);
54+
}
55+
3656
public static void Warn(this INHibernateLogger logger, Exception exception, string format, params object[] args)
3757
{
3858
logger.Log(InternalLogLevel.Warn, new InternalLogValues(format, args), exception);
3959
}
4060

61+
public static void Warn(this INHibernateLogger logger, Exception exception, string format)
62+
{
63+
logger.Log(InternalLogLevel.Warn, new InternalLogValues(format, null), exception);
64+
}
65+
4166
public static void Warn(this INHibernateLogger logger, string format, params object[] args)
4267
{
4368
logger.Log(InternalLogLevel.Warn, new InternalLogValues(format, args), null);
4469
}
4570

71+
public static void Warn(this INHibernateLogger logger, string format)
72+
{
73+
logger.Log(InternalLogLevel.Warn, new InternalLogValues(format, null), null);
74+
}
75+
4676
public static void Info(this INHibernateLogger logger, Exception exception, string format, params object[] args)
4777
{
4878
logger.Log(InternalLogLevel.Info, new InternalLogValues(format, args), exception);
4979
}
5080

81+
public static void Info(this INHibernateLogger logger, Exception exception, string format)
82+
{
83+
logger.Log(InternalLogLevel.Info, new InternalLogValues(format, null), exception);
84+
}
85+
5186
public static void Info(this INHibernateLogger logger, string format, params object[] args)
5287
{
5388
logger.Log(InternalLogLevel.Info, new InternalLogValues(format, args), null);
5489
}
5590

91+
public static void Info(this INHibernateLogger logger, string format)
92+
{
93+
logger.Log(InternalLogLevel.Info, new InternalLogValues(format, null), null);
94+
}
95+
5696
public static void Debug(this INHibernateLogger logger, Exception exception, string format, params object[] args)
5797
{
5898
logger.Log(InternalLogLevel.Debug, new InternalLogValues(format, args), exception);
5999
}
60100

101+
public static void Debug(this INHibernateLogger logger, Exception exception, string format)
102+
{
103+
logger.Log(InternalLogLevel.Debug, new InternalLogValues(format, null), exception);
104+
}
105+
61106
public static void Debug(this INHibernateLogger logger, string format, params object[] args)
62107
{
63108
logger.Log(InternalLogLevel.Debug, new InternalLogValues(format, args), null);
64109
}
65110

111+
public static void Debug(this INHibernateLogger logger, string format)
112+
{
113+
logger.Log(InternalLogLevel.Debug, new InternalLogValues(format, null), null);
114+
}
115+
66116

67117
// catch any method calls with an Exception argument second as they would otherwise silently be consumed by `params object[] args`.
68118

@@ -101,4 +151,4 @@ private static void ThrowNotImplemented()
101151
throw new NotImplementedException("Should not have compiled with call to this method");
102152
}
103153
}
104-
}
154+
}

0 commit comments

Comments
 (0)