OCPPLog.cs 13 KB

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