PythonShareLog.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //using System;
  2. //using System.Threading;
  3. //using Thrift.Protocol;
  4. //using Thrift.Server;
  5. //using Thrift.Transport;
  6. //namespace WWPipeLine.Commons
  7. //{
  8. // public class PythonShareLog
  9. // {
  10. // public delegate void SendMsg(string msg, string type);
  11. // //Python日志推送事件
  12. // public static event SendMsg SendMsgEvent;
  13. // private static string _instance = null;
  14. // private static object _instanceLock = new object();
  15. // /// <summary>
  16. // /// Python日志服务状态
  17. // /// </summary>
  18. // public const string _shareLogServerStatus = "OK";
  19. // /// <summary>
  20. // /// 获取Thrift服务单例
  21. // /// </summary>
  22. // public static string Instance
  23. // {
  24. // get
  25. // {
  26. // if (_instance == null)
  27. // {
  28. // lock (_instanceLock)
  29. // {
  30. // if (_instance == null)
  31. // {
  32. // _instance = _shareLogServerStatus;
  33. // ThreadPool.QueueUserWorkItem((s) => { new PythonShareLog().InitServer(); });
  34. // }
  35. // }
  36. // }
  37. // return _instance;
  38. // }
  39. // set { _instance = value; }
  40. // }
  41. // private void InitServer(bool isReptile = false)
  42. // {
  43. // try
  44. // {
  45. // TServerSocket reptile_ServerTransport = new TServerSocket(8848);
  46. // ShareLogService shareLog = new ShareLogService();
  47. // ShareLog.Processor logProcessor = new ShareLog.Processor(shareLog);
  48. // shareLog.SendMsgEvent -= ShareLog_SendMsgEvent;
  49. // shareLog.SendMsgEvent += ShareLog_SendMsgEvent; ;
  50. // TMultiplexedProcessor process = new TMultiplexedProcessor();
  51. // process.RegisterProcessor("LogShareServer", logProcessor);
  52. // TServer server = new TThreadPoolServer(process, reptile_ServerTransport);
  53. // server.Serve();
  54. // }
  55. // catch (Exception ex)
  56. // {
  57. // Commons.LogHelper.Error(ex);
  58. // }
  59. // }
  60. // private void ShareLog_SendMsgEvent(string msg, string type)
  61. // {
  62. // SendMsgEvent?.Invoke(msg, type);
  63. // }
  64. // }
  65. //}