private void LoopTran() { byte[] buffer = new byte[BufferSize]; logger.Info($"listener prepare to receive {this.GetHashCode()}"); var result = opendSocket.Receive(buffer, SocketFlags.None, out var errorCode); if (result < 0 || errorCode != SocketError.Success) { breakLoopTrace = true; logger.Error($"Socket closed by client! {errorCode}"); throw new Exception($"Socket closed by client! {errorCode}"); } else if (result > 0) { Array.Resize <byte>(ref buffer, result); if (!opendSocks5Client.Send(buffer, out var code)) { logger.Error(code.ToString()); } else { logger.Debug("Send data:" + Encoding.UTF8.GetString(buffer)); } } }
public ExampleServiceServiceProvider() { _logger.Debug("ExampleServiceServiceProvider() constructor"); _channel = new ManualChannelFactory <ExampleServiceSoapChannel>(ContractName); _service = _channel.CreateChannel(); _logger.Debug("ExampleServiceServiceProvider channel created"); }
private void LogMessageString(bool sent, MessageEvent messageEvent) { if (_logger.ToPrint.DoesPrint(LogLevel.Debug)) { var verb = sent ? "Sent" : "Received"; var logString = $"Text {verb}: {messageEvent.Message}"; _logger.Debug(logString); } }
protected void Application_Start() { _logger.Debug("Application_Start()"); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); SessionManager.CreateFactory(); }
public static void TestConnection() { _logger.Debug("Test ExampleServiceServiceProvider connection"); var provider = new ExampleServiceServiceProvider(); _logger.Debug("Open connection"); provider.Service.Open(); _logger.Debug("Close connection"); provider.Service.Close(); _logger.Debug("Done"); provider.Dispose(); }
public static void TestLogging() { BaseLogger logger = Logger.GetLogger(typeof(Logging)); logger.Debug("Debug message"); logger.Info("Info message"); logger.Error("Error message"); }
/// <summary> /// Create a new NHibernate factory and save reference in CurrentFactory property /// </summary> /// <returns></returns> public static void CreateFactory() { _logger.Debug("Creating NHibernate session factory"); try { // Create and configure factory ISessionFactory factory = Fluently.Configure() .Database(Configuration.Database.NHibernateConfiguration()) .Mappings(m => m.FluentMappings.AddFromAssemblyOf <BaseMapping <Object> >()) .BuildSessionFactory(); CurrentFactory = factory; } catch (FluentConfigurationException ex) { _logger.Error("Fatal exception occured while creating NHibernate session factory", ex); throw; } }
public static void ArrayDebug(params object[] values) { if (LogLevel.DEBUG == (BaseLogger.currentLogLevels & LogLevel.DEBUG)) { string msg = "Array: "; for (int i = 0; i < values.Length; ++i) { msg += values[i] + ((i == values.Length - 1 && i != 0) ? ", " : ""); } BaseLogger.Debug(msg); } }
/// <summary> /// Exports the object model to the database schema /// </summary> /// <param name="updateDatabase">If true the schema is committed to the database</param> /// <param name="saveScript">If true saves the update script to a file</param> /// <param name="scriptFile">Path of the file to save the script to</param> /// <returns>true if export succeeded</returns> public static bool ExportObjectModel(bool updateDatabase, bool saveScript, string scriptFile = null) { _logger.Debug("ExportObjectModel(updateDatabase:{0}, saveScript:{1}, scriptFile:{2})", updateDatabase, saveScript, scriptFile); if (!updateDatabase && !saveScript) { _logger.Error("ExportObjectModel() requires either updateDatabase or saveScript to be true"); return(false); } else if (updateDatabase && !Configuration.Database.AllowSchemaUpdate) { _logger.Error("Update of database schema is prevented by configuration (Configuration.Database.AllowSchemaUpdate=false)"); return(false); } try { // Load NHibernate configuration FluentConfiguration config = Fluently.Configure() .Database(Configuration.Database.NHibernateConfiguration()) .Mappings(m => m.FluentMappings.AddFromAssemblyOf <BaseMapping <Object> >()); // Setup SchemaExport var export = new SchemaExport(config.BuildConfiguration()); if (!String.IsNullOrEmpty(scriptFile)) { export.SetOutputFile(scriptFile); } // Execute export.Execute(saveScript, updateDatabase, false); _logger.Debug("ExportObjectModel succeeded"); return(true); } catch (Exception ex) { _logger.Error("ExportObjectModel failed", ex); return(false); } }
/// <summary> /// Flush the queue. /// </summary> internal async Task Flush(bool fromEvent = false) { if (!Connected()) { return; } _logger.Debug("Flushing connection message queue"); JObject _queueToFlush = null; lock (_queueLock) { if (fromEvent) { _hasQueueEvent = false; } if (_subscriptionValueQueue.Count != 0) { var response = new JObject { { "rid", 0 }, { "updates", _subscriptionValueQueue } }; if (_queue == null) { _queue = new JObject { { "responses", new JArray() } }; } _queue["responses"].Value <JArray>().Add(response); } if (_queue != null) { _queueToFlush = _queue; _queue = null; } if (_subscriptionValueQueue.Count != 0) { _subscriptionValueQueue = new JArray(); } } if (_queueToFlush != null) { await Write(_queueToFlush, false); } }
/// <summary> /// Returns web services configuration /// </summary> /// <returns>Configuration</returns> public static System.Configuration.Configuration GetServicesConfiguration() { try { if (_logger != null) { _logger.Debug("Configuration.GetServicesConfiguration()"); } ExeConfigurationFileMap executionFileMap = new ExeConfigurationFileMap(); executionFileMap.ExeConfigFilename = GetConfigPath("Services.xml"); return(ConfigurationManager.OpenMappedExeConfiguration(executionFileMap, ConfigurationUserLevel.None)); } catch (Exception ex) { if (_logger != null) { _logger.Error("Error occured in Configuration.GetServicesConfiguration()", ex); } throw new CustomException("Error occured in Configuration.GetServicesConfiguration()", ex); } }
public static void Test(bool comparison, object message = null, params object[] argv) { if (comparison) { return; } if (LogLevel.DEBUG == (BaseLogger.currentLogLevels & LogLevel.DEBUG)) { string messageFormat = ""; if (message != null) { messageFormat = BaseLogger.LoggerStringFormat(message.ToString(), argv); } else { messageFormat = "comparison not pass!!"; } BaseLogger.Debug("Test + " + messageFormat + " #"); } }
/// <summary> /// Load a single T object with specified id /// </summary> /// <param name="id"></param> /// <returns></returns> public static T Load(int id) { _logger.Debug("{0}.Load({1})", typeof(T), id); var result = SessionManager.CurrentSession.Get <T>(id); _logger.Debug((result != null) ? "Found object" : "Object not found"); return(result); }
/// <summary> /// Set the page title for current view /// </summary> /// <param name="pageName"></param> public void SetTitle(string pageName) { _logger.Debug("Set page title for \"{0}\"", pageName); ViewBag.Title = TitleFor(pageName); }
public new static void Debug(string message) { Singleton.Debug(message); }
/// <summary> /// Returns translation for sepcified SystemMessage /// </summary> /// <param name="key"></param> /// <returns></returns> public static string Translate(SystemMessages key) { _logger.Debug("Translate(SystemMessages.{0})", key); return(Translate(SystemMessagePrefix + key.ToString())); }
public static void Debug(object message, params object[] argv) { BaseLogger.Debug(message, argv); }
public static void TestCrud() { _logger.Debug("Test: TestCrud()"); string name = "Blaaaa " + DateTime.Now.ToString(); _logger.Debug("Creating new Example() object with name {0}", name); var example = new TestObject(); example.Name = "Blaaaa " + DateTime.Now.ToString(); example.Save(); SessionManager.FlushSession(); _logger.Debug("Load Example object with name {0}", name); example = TestObject.Load(SessionManager.CurrentSession.QueryOver <TestObject>().Where(x => x.Name == name).UnderlyingCriteria); _logger.Debug((example != null) ? String.Format("Found example object (id={0})", example.Id) : "Could not find example object"); if (example != null) { _logger.Debug("Update Example object with id {0}", example.Id); example.Name = "Bla bla updated !!!"; example.Update(); SessionManager.FlushSession(); _logger.Debug("Load Example object with id {0}", example.Id); example = TestObject.Load(example.Id); _logger.Debug("Example.Name = {0}", example.Name); } for (int i = 0; i < 2; i++) { _logger.Debug("Checking for existing Example() object with name 'BAAA'"); example = TestObject.ExistsWithCriteria(new TestObject { Name = "BAAA" }, SessionManager.CurrentSession.QueryOver <TestObject>().Where(x => x.Name == "BAAA").UnderlyingCriteria); example.SaveOrUpdate(); SessionManager.FlushSession(); if (i == 0) { _logger.Debug("Now do it again!"); } } int id = example.Id; _logger.Debug("Delete the BAAA record (id={0})", id); example.Delete(); SessionManager.FlushSession(); _logger.Debug("Check if record with id {0} exists", id); _logger.Debug("Example.Exists({0}) = {1}", id, TestObject.Exists(id)); }