Beispiel #1
0
        /// <summary>
        /// Takes care of the initial handshaking between the the client and the server
        /// </summary>


        private void Log(string str, ServerLogLevel level)
        {
            if (Logger != null && (int)LogLevel >= (int)level)
            {
                Logger.Write(str);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Configure the Http server
 /// </summary>
 /// <param name="messageEncoding">Encoding used for the body of the Http messages</param>
 /// <param name="logLevel">Verbosity of the logs written by the Http server</param>
 /// <param name="logWriter">Stream used to write all the logs of the Http server</param>
 public StdioHttpServer(Encoding messageEncoding, ServerLogLevel logLevel, StreamWriter logWriter)
 {
     this.messageEncoding = messageEncoding;
     this.logLevel = logLevel;
     this.logWriter = logWriter;
     this.logWriter.AutoFlush = true;
 }
Beispiel #3
0
        public ConsoleLogger(ServerLogLevel logLevel, string logFolderPath)
        {
            m_bCreated      = false;
            LogLevel        = logLevel;
            m_LogFolderPath = logFolderPath;

            try
            {
                if (!Directory.Exists(m_LogFolderPath))
                {
                    Directory.CreateDirectory(m_LogFolderPath);
                }

                m_LogFilePath = String.Format("{0}{1}.log", m_LogFolderPath, DateTime.Now.ToString("yyyyMMdd"));
                if (!File.Exists(m_LogFilePath))
                {
                    using (StreamWriter sw = File.CreateText(m_LogFilePath))
                    {
                        sw.WriteLine("--------- Created");
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                return;
            }
            m_bCreated = true;
        }
Beispiel #4
0
        public virtual void Save(LoggingSettingsTo logSettings)
        {
            logSettings.LogLevel = ServerLogLevel.ToString();
            logSettings.LogSize  = int.Parse(ServerLogMaxSize);
            var settingsConfigFile = HelperUtils.GetStudioLogSettingsConfigFile();

            Dev2Logger.WriteLogSettings(StudioLogMaxSize, StudioLogLevel.ToString(), settingsConfigFile);
        }
Beispiel #5
0
 /// <summary>
 /// Configure the Http server
 /// </summary>
 /// <param name="messageEncoding">Encoding used for the body of the Http messages</param>
 /// <param name="logLevel">Verbosity of the logs written by the Http server</param>
 /// <param name="logWriter">Text Writer used to write all the logs of the Http server</param>
 public StdioHttpServer(Encoding messageEncoding, ServerLogLevel logLevel, TextWriter logWriter)
 {
     this.messageEncoding = messageEncoding;
     this.logLevel        = logLevel;
     this.logWriter       = logWriter;
     if (logWriter is StreamWriter)
     {
         (this.logWriter as StreamWriter).AutoFlush = true;
     }
 }
        /// <summary>
        /// Сохранить настройки.
        /// </summary>
        /// <param name="storage">Хранилище настроек.</param>
        public override void Save(SettingsStorage storage)
        {
            base.Save(storage);

            storage.SetValue("Address", Address.To <string>());
            storage.SetValue("ClientId", ClientId);
            storage.SetValue("IsRealTimeMarketData", IsRealTimeMarketData);
            storage.SetValue("ServerLogLevel", ServerLogLevel.To <string>());
            storage.SetValue("Fields", Fields.Select(t => t.To <string>()).Join(","));
        }
Beispiel #7
0
 /// <summary>
 /// Configure the Http server
 /// </summary>
 /// <param name="messageEncoding">Encoding used for the body of the Http messages</param>
 /// <param name="logLevel">Verbosity of the logs written by the Http server</param>
 /// <param name="logWriter">Text Writer used to write all the logs of the Http server</param>
 public StdioHttpServer(Encoding messageEncoding, ServerLogLevel logLevel, TextWriter logWriter)
 {
     this.messageEncoding   = messageEncoding;
     this.logLevel          = logLevel;
     this.logWriter         = logWriter;
     Console.OutputEncoding = messageEncoding ?? Encoding.UTF8;
     Console.InputEncoding  = messageEncoding ?? Encoding.UTF8;
     if (logWriter is StreamWriter)
     {
         (this.logWriter as StreamWriter).AutoFlush = true;
     }
 }
Beispiel #8
0
 /// <summary>
 /// Configure the Http server
 /// </summary>
 /// <param name="messageEncoding">Encoding used for the body of the Http messages</param>
 /// <param name="logLevel">Verbosity of the logs written by the Http server</param>
 /// <param name="logWriter">Text Writer used to write all the logs of the Http server</param>
 public StdioHttpServer(Encoding messageEncoding, ServerLogLevel logLevel, TextWriter logWriter, Queue <MessageActionWrapper> messagesQueue)
 {
     this.messageEncoding   = messageEncoding;
     this.logLevel          = logLevel;
     this.logWriter         = logWriter;
     this.messagesQueue     = messagesQueue;
     Console.OutputEncoding = messageEncoding ?? Encoding.UTF8;
     Console.InputEncoding  = messageEncoding ?? Encoding.UTF8;
     if (logWriter is StreamWriter)
     {
         ((StreamWriter)this.logWriter).AutoFlush = true;
     }
 }
Beispiel #9
0
        /// <summary>
        /// Collect Arguments
        /// </summary>
        /// <param name="args">The arguments</param>
        /// <param name="logLevel">Output: The LogLevel from the arguments</param>
        /// <param name="logWriter">Output: The Log Writer from the arguments</param>
        static void GetArguments(String[] args, out ServerLogLevel logLevel, out TextWriter logWriter)
        {
            logLevel  = ServerLogLevel.Lifecycle;
            logWriter = null;
            try
            {
                if (args != null && args.Length != 0)
                {//Standard output
                    try
                    {
                        // args[0] : Trace level
                        logLevel = (ServerLogLevel)Int32.Parse(args[0]);
                        if (!System.Enum.IsDefined(typeof(ServerLogLevel), (Int32)logLevel))
                        {
                            ;
                        }
                        {
                            logLevel = ServerLogLevel.Protocol;
                        }
                    }
                    catch (Exception e)
                    {
                        System.Console.Error.WriteLine(e.Message);
                    }

                    if (args.Length > 1)
                    {
                        // Open log file
                        // args[1] : Log file name
                        string logFile = args[1];
                        try
                        {
                            StreamWriter sw = new StreamWriter(logFile);
                            sw.AutoFlush = true;
                            logWriter    = sw;
                        }
                        catch (Exception e)
                        {
                            System.Console.Error.WriteLine(e.Message);
                        }
                    }
                }
            }
            finally
            {
                if (logWriter == null)
                {
                    logWriter = new DebugTextWriter();
                }
            }
        }
Beispiel #10
0
 private void LogLine(string str, ServerLogLevel level)
 {
     Log(str + "\r\n", level);
 }
Beispiel #11
0
 private void LogLine(string str, ServerLogLevel level)
 {
     Log(str + "\r\n", level);
 }
Beispiel #12
0
 private void Log(string str, ServerLogLevel level)
 {
     if (Logger != null && (int)LogLevel >= (int)level)
     {
         Logger.Write(str);
     }
 }
Beispiel #13
0
 /// <summary>
 /// The default level is ERROR. Refer to the API logging page for more details.
 /// </summary>
 /// <param name="serverLogLevel">
 /// logLevel - specifies the level of log entry detail used by the server (TWS) when processing API requests. Valid values include:
 /// 1 = SYSTEM
 /// 2 = ERROR
 /// 3 = WARNING
 /// 4 = INFORMATION
 /// 5 = DETAIL
 /// </param>
 public void SetServerLogLevel(ServerLogLevel serverLogLevel)
 {
     lock (this)
         ClientSocket.setServerLogLevel((int)serverLogLevel);
 }
Beispiel #14
0
 private void Log(string p, ServerLogLevel serverLogLevel)
 {
     if (logger != null && (int)LogLevel >= (int)serverLogLevel)
     {
         Logger.Write(p);
     }
 }