OCPPLog.cs 13 KB

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