OCPPLog.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. using NLog;
  2. using NLog.Fluent;
  3. using SuperSocket.SocketBase.Logging;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace OCPPServer.SubProtocol
  10. {
  11. public class OCPPLog : ILog
  12. {
  13. private NLog.ILogger m_Log;
  14. public OCPPLog(string name)
  15. {
  16. m_Log = NLog.LogManager.GetCurrentClassLogger();
  17. }
  18. /// <summary>
  19. /// Gets a value indicating whether this instance is debug enabled.
  20. /// </summary>
  21. /// <value>
  22. /// <c>true</c> if this instance is debug enabled; otherwise, <c>false</c>.
  23. /// </value>
  24. public bool IsDebugEnabled
  25. {
  26. get { return m_Log.IsDebugEnabled; }
  27. }
  28. /// <summary>
  29. /// Gets a value indicating whether this instance is error enabled.
  30. /// </summary>
  31. /// <value>
  32. /// <c>true</c> if this instance is error enabled; otherwise, <c>false</c>.
  33. /// </value>
  34. public bool IsErrorEnabled
  35. {
  36. get { return m_Log.IsErrorEnabled; }
  37. }
  38. /// <summary>
  39. /// Gets a value indicating whether this instance is fatal enabled.
  40. /// </summary>
  41. /// <value>
  42. /// <c>true</c> if this instance is fatal enabled; otherwise, <c>false</c>.
  43. /// </value>
  44. public bool IsFatalEnabled
  45. {
  46. get { return m_Log.IsFatalEnabled; }
  47. }
  48. /// <summary>
  49. /// Gets a value indicating whether this instance is info enabled.
  50. /// </summary>
  51. /// <value>
  52. /// <c>true</c> if this instance is info enabled; otherwise, <c>false</c>.
  53. /// </value>
  54. public bool IsInfoEnabled
  55. {
  56. get { return m_Log.IsInfoEnabled; }
  57. }
  58. /// <summary>
  59. /// Gets a value indicating whether this instance is warn enabled.
  60. /// </summary>
  61. /// <value>
  62. /// <c>true</c> if this instance is warn enabled; otherwise, <c>false</c>.
  63. /// </value>
  64. public bool IsWarnEnabled
  65. {
  66. get { return m_Log.IsWarnEnabled; }
  67. }
  68. /// <summary>
  69. /// Logs the debug message.
  70. /// </summary>
  71. /// <param name="message">The message.</param>
  72. public void Debug(object message)
  73. {
  74. m_Log.Debug(message);
  75. }
  76. /// <summary>
  77. /// Logs the debug message.
  78. /// </summary>
  79. /// <param name="message">The message.</param>
  80. /// <param name="exception">The exception.</param>
  81. public void Debug(object message, Exception exception)
  82. {
  83. //m_Log.Debug((System.IFormatProvider)message, exception);
  84. m_Log.Debug(exception, message.ToString());
  85. }
  86. /// <summary>
  87. /// Logs the debug message.
  88. /// </summary>
  89. /// <param name="format">The format.</param>
  90. /// <param name="arg0">The arg0.</param>
  91. public void DebugFormat(string format, object arg0)
  92. {
  93. }
  94. /// <summary>
  95. /// Logs the debug message.
  96. /// </summary>
  97. /// <param name="format">The format.</param>
  98. /// <param name="args">The args.</param>
  99. public void DebugFormat(string format, params object[] args)
  100. {
  101. }
  102. /// <summary>
  103. /// Logs the debug message.
  104. /// </summary>
  105. /// <param name="provider">The provider.</param>
  106. /// <param name="format">The format.</param>
  107. /// <param name="args">The args.</param>
  108. public void DebugFormat(IFormatProvider provider, string format, params object[] args)
  109. {
  110. }
  111. /// <summary>
  112. /// Logs the debug message.
  113. /// </summary>
  114. /// <param name="format">The format.</param>
  115. /// <param name="arg0">The arg0.</param>
  116. /// <param name="arg1">The arg1.</param>
  117. public void DebugFormat(string format, object arg0, object arg1)
  118. {
  119. }
  120. /// <summary>
  121. /// Logs the debug message.
  122. /// </summary>
  123. /// <param name="format">The format.</param>
  124. /// <param name="arg0">The arg0.</param>
  125. /// <param name="arg1">The arg1.</param>
  126. /// <param name="arg2">The arg2.</param>
  127. public void DebugFormat(string format, object arg0, object arg1, object arg2)
  128. {
  129. }
  130. /// <summary>
  131. /// Logs the error message.
  132. /// </summary>
  133. /// <param name="message">The message.</param>
  134. public void Error(object message)
  135. {
  136. m_Log.Error(message);
  137. }
  138. /// <summary>
  139. /// Logs the error message.
  140. /// </summary>
  141. /// <param name="message">The message.</param>
  142. /// <param name="exception">The exception.</param>
  143. public void Error(object message, Exception exception)
  144. {
  145. //m_Log.Error((System.IFormatProvider)message, exception);
  146. m_Log.Error(exception, message.ToString());
  147. }
  148. /// <summary>
  149. /// Logs the error message.
  150. /// </summary>
  151. /// <param name="format">The format.</param>
  152. /// <param name="arg0">The arg0.</param>
  153. public void ErrorFormat(string format, object arg0)
  154. {
  155. }
  156. /// <summary>
  157. /// Logs the error message.
  158. /// </summary>
  159. /// <param name="format">The format.</param>
  160. /// <param name="args">The args.</param>
  161. public void ErrorFormat(string format, params object[] args)
  162. {
  163. }
  164. /// <summary>
  165. /// Logs the error message.
  166. /// </summary>
  167. /// <param name="provider">The provider.</param>
  168. /// <param name="format">The format.</param>
  169. /// <param name="args">The args.</param>
  170. public void ErrorFormat(IFormatProvider provider, string format, params object[] args)
  171. {
  172. }
  173. /// <summary>
  174. /// Logs the error message.
  175. /// </summary>
  176. /// <param name="format">The format.</param>
  177. /// <param name="arg0">The arg0.</param>
  178. /// <param name="arg1">The arg1.</param>
  179. public void ErrorFormat(string format, object arg0, object arg1)
  180. {
  181. }
  182. /// <summary>
  183. /// Logs the error message.
  184. /// </summary>
  185. /// <param name="format">The format.</param>
  186. /// <param name="arg0">The arg0.</param>
  187. /// <param name="arg1">The arg1.</param>
  188. /// <param name="arg2">The arg2.</param>
  189. public void ErrorFormat(string format, object arg0, object arg1, object arg2)
  190. {
  191. }
  192. /// <summary>
  193. /// Logs the fatal error message.
  194. /// </summary>
  195. /// <param name="message">The message.</param>
  196. public void Fatal(object message)
  197. {
  198. m_Log.Fatal(message);
  199. }
  200. /// <summary>
  201. /// Logs the fatal error message.
  202. /// </summary>
  203. /// <param name="message">The message.</param>
  204. /// <param name="exception">The exception.</param>
  205. public void Fatal(object message, Exception exception)
  206. {
  207. m_Log.Fatal((System.IFormatProvider)message, exception);
  208. }
  209. /// <summary>
  210. /// Logs the fatal error message.
  211. /// </summary>
  212. /// <param name="format">The format.</param>
  213. /// <param name="arg0">The arg0.</param>
  214. public void FatalFormat(string format, object arg0)
  215. {
  216. }
  217. /// <summary>
  218. /// Logs the fatal error message.
  219. /// </summary>
  220. /// <param name="format">The format.</param>
  221. /// <param name="args">The args.</param>
  222. public void FatalFormat(string format, params object[] args)
  223. {
  224. }
  225. /// <summary>
  226. /// Logs the fatal error message.
  227. /// </summary>
  228. /// <param name="provider">The provider.</param>
  229. /// <param name="format">The format.</param>
  230. /// <param name="args">The args.</param>
  231. public void FatalFormat(IFormatProvider provider, string format, params object[] args)
  232. {
  233. }
  234. /// <summary>
  235. /// Logs the fatal error message.
  236. /// </summary>
  237. /// <param name="format">The format.</param>
  238. /// <param name="arg0">The arg0.</param>
  239. /// <param name="arg1">The arg1.</param>
  240. public void FatalFormat(string format, object arg0, object arg1)
  241. {
  242. }
  243. /// <summary>
  244. /// Logs the fatal error message.
  245. /// </summary>
  246. /// <param name="format">The format.</param>
  247. /// <param name="arg0">The arg0.</param>
  248. /// <param name="arg1">The arg1.</param>
  249. /// <param name="arg2">The arg2.</param>
  250. public void FatalFormat(string format, object arg0, object arg1, object arg2)
  251. {
  252. }
  253. /// <summary>
  254. /// Logs the info message.
  255. /// </summary>
  256. /// <param name="message">The message.</param>
  257. public void Info(object message)
  258. {
  259. m_Log.Info(message);
  260. }
  261. /// <summary>
  262. /// Logs the info message.
  263. /// </summary>
  264. /// <param name="message">The message.</param>
  265. /// <param name="exception">The exception.</param>
  266. public void Info(object message, Exception exception)
  267. {
  268. //m_Log.Info((System.IFormatProvider)message, exception);
  269. m_Log.Info(exception, message.ToString());
  270. }
  271. /// <summary>
  272. /// Logs the info message.
  273. /// </summary>
  274. /// <param name="format">The format.</param>
  275. /// <param name="arg0">The arg0.</param>
  276. public void InfoFormat(string format, object arg0)
  277. {
  278. }
  279. /// <summary>
  280. /// Logs the info message.
  281. /// </summary>
  282. /// <param name="format">The format.</param>
  283. /// <param name="args">The args.</param>
  284. public void InfoFormat(string format, params object[] args)
  285. {
  286. }
  287. /// <summary>
  288. /// Logs the info message.
  289. /// </summary>
  290. /// <param name="provider">The provider.</param>
  291. /// <param name="format">The format.</param>
  292. /// <param name="args">The args.</param>
  293. public void InfoFormat(IFormatProvider provider, string format, params object[] args)
  294. {
  295. }
  296. /// <summary>
  297. /// Logs the info message.
  298. /// </summary>
  299. /// <param name="format">The format.</param>
  300. /// <param name="arg0">The arg0.</param>
  301. /// <param name="arg1">The arg1.</param>
  302. public void InfoFormat(string format, object arg0, object arg1)
  303. {
  304. }
  305. /// <summary>
  306. /// Logs the info message.
  307. /// </summary>
  308. /// <param name="format">The format.</param>
  309. /// <param name="arg0">The arg0.</param>
  310. /// <param name="arg1">The arg1.</param>
  311. /// <param name="arg2">The arg2.</param>
  312. public void InfoFormat(string format, object arg0, object arg1, object arg2)
  313. {
  314. }
  315. /// <summary>
  316. /// Logs the warning message.
  317. /// </summary>
  318. /// <param name="message">The message.</param>
  319. public void Warn(object message)
  320. {
  321. m_Log.Warn(message);
  322. }
  323. /// <summary>
  324. /// Logs the warning message.
  325. /// </summary>
  326. /// <param name="message">The message.</param>
  327. /// <param name="exception">The exception.</param>
  328. public void Warn(object message, Exception exception)
  329. {
  330. //m_Log.Warn((System.IFormatProvider)message, exception);
  331. m_Log.Warn(exception, message.ToString());
  332. }
  333. /// <summary>
  334. /// Logs the warning message.
  335. /// </summary>
  336. /// <param name="format">The format.</param>
  337. /// <param name="arg0">The arg0.</param>
  338. public void WarnFormat(string format, object arg0)
  339. {
  340. }
  341. /// <summary>
  342. /// Logs the warning message.
  343. /// </summary>
  344. /// <param name="format">The format.</param>
  345. /// <param name="args">The args.</param>
  346. public void WarnFormat(string format, params object[] args)
  347. {
  348. }
  349. /// <summary>
  350. /// Logs the warning message.
  351. /// </summary>
  352. /// <param name="provider">The provider.</param>
  353. /// <param name="format">The format.</param>
  354. /// <param name="args">The args.</param>
  355. public void WarnFormat(IFormatProvider provider, string format, params object[] args)
  356. {
  357. }
  358. /// <summary>
  359. /// Logs the warning message.
  360. /// </summary>
  361. /// <param name="format">The format.</param>
  362. /// <param name="arg0">The arg0.</param>
  363. /// <param name="arg1">The arg1.</param>
  364. public void WarnFormat(string format, object arg0, object arg1)
  365. {
  366. }
  367. /// <summary>
  368. /// Logs the warning message.
  369. /// </summary>
  370. /// <param name="format">The format.</param>
  371. /// <param name="arg0">The arg0.</param>
  372. /// <param name="arg1">The arg1.</param>
  373. /// <param name="arg2">The arg2.</param>
  374. public void WarnFormat(string format, object arg0, object arg1, object arg2)
  375. {
  376. }
  377. }
  378. }