public void AddLog(LogEntry l)
		{
			m_items.Add (l);
			if (m_items.Count >= Engine.Instance.Storage.GetInt ("gui.log_limit"))
				m_items.RemoveAt (0);
			RefreshUI ();
		}
Beispiel #2
0
        public virtual void OnLog(LogEntry l)
        {
			// An exception, to have a clean, standard 'man' output without logging header.
			if (CommandLine.SystemEnvironment.Exists("help"))
			{
				Console.WriteLine(l.Message);
				return;
			}

			if (l.Type != LogType.Realtime)
			{
				string lines = l.GetStringLines().Trim();
				Console.WriteLine(lines);

				// File logging

				if (Storage != null)
				{
					lock (Storage)
					{
						if (Storage.GetBool("log.file.enabled"))
						{
							try
							{
								string logPath = Storage.Get("log.file.path").Trim();

								List<string> paths = ParseLogFilePath(logPath);
								foreach (string path in paths)
								{
									Directory.CreateDirectory(Path.GetDirectoryName(path));
									File.AppendAllText(path, lines + "\n");
								}
							}
							catch(Exception e) 
							{
								Log (LogType.Warning, Messages.Format("Log to file disabled due to error, {1}", e.Message));
								Storage.SetBool ("log.file.enabled", false);
							}
						}
					}
				}
			}
        }
Beispiel #3
0
        public void Log(LogType Type, string Message, int BalloonTime, Exception e)
        {
			// Avoid repetition
			if (Message == m_logLast)
				return;
			m_logLast = Message;

            LogEntry l = new LogEntry();
            l.Type = Type;
            l.Message = Message;
            l.BalloonTime = BalloonTime;
			l.Exception = e;

			if (l.Type > Engine.LogType.Realtime)
			{
				m_lastLogMessage = l.Message;
				m_logDotCount += 1;
				m_logDotCount = m_logDotCount % 10;
			}

            OnLog(l);
        }
Beispiel #4
0
        public override void OnLog(LogEntry l)
        {
			base.OnLog(l);
			
			if( (Engine.Storage == null) || (Engine.Storage.GetBool("cli") == false) )
			{
				lock (LogEntries)
				{
					LogEntries.Add(l);
				}
				if (FormMain != null)
					FormMain.RefreshUi(RefreshUiMode.Log);            
				
				if (FormMain == null) // Otherwise it's showed from the RefreshUI in the same UI Thread
				{
					if (l.Type == LogType.Fatal)
					{
						MessageBox.Show(FormMain, l.Message, Constants.Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
					}
				}
			}
        }
Beispiel #5
0
		public override void OnLog (LogEntry l)
		{
			base.OnLog (l);

			lock (LogsPending) {
				LogsPending.Add (l);
			}

			OnRefreshUi (RefreshUiMode.Log);


		}
Beispiel #6
0
        public void Log(LogEntry l)
        {
            if (this.InvokeRequired)
            {

                LogDelegate inv = new LogDelegate(this.Log);

                this.BeginInvoke(inv, new object[] { l });                
            }
            else
            {
                lock (this)
                {
                    string Msg = l.Message;

                    if (l.Type > Engine.LogType.Realtime)
                    {
                        ListViewItemLog Item = new ListViewItemLog();
						Item.ImageKey = l.Type.ToString().ToLowerInvariant();
						Item.Text = "";
						Item.SubItems.Add(l.GetDateForList());
						Item.SubItems.Add(l.GetMessageForList());
						Item.ToolTipText = l.Message;
						Item.Info = l;

						lstLogs.Items.Add(Item);
						Item.EnsureVisible();

						if (lstLogs.Items.Count >= Engine.Storage.GetInt("gui.log_limit"))
							lstLogs.Items.RemoveAt(0);
                    }

                    if ((Msg != "") && (l.Type != Engine.LogType.Verbose))
                    {
                        String ShortMsg = Msg;
                        if (ShortMsg.Length > 40)
                            ShortMsg = ShortMsg.Substring(0, 40) + "...";

						string notifyText = Constants.Name + " - " + ShortMsg;

						//if(Engine.IsConnected() == false)
						{
							Text = Constants.Name + " - " + Msg;

							mnuStatus.Text = "> " + Msg;

							if (m_notifyIcon != null)
							{
								m_notifyIcon.Text = notifyText;
								m_notifyIcon.BalloonTipText = Msg;
								if(l.Type >= Engine.LogType.InfoImportant)
									m_notifyIcon.ShowBalloonTip(l.BalloonTime);
							}
						}
                    }

                    if (l.Type == Engine.LogType.Fatal)
                    {
                        MessageBox.Show(this, Msg, Constants.Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

					
                }
            }
        }
		public void Log(LogEntry l)
		{
			string msg = l.Message;

			TableLogsController.AddLog (l);

			StatusItem.ToolTip = msg;

			if ((msg != "") && (l.Type != Core.Engine.LogType.Verbose)) {
				if(Engine.IsConnected() == false)
				{
					Window.Title = Constants.Name + " - " + msg;
					MnuTrayStatus.Title = "> " + msg;
				}
			}

			if (l.Type >= Engine.LogType.InfoImportant)
				Notification (msg, "");

			if (l.Type >= Engine.LogType.InfoImportant)
				RequestAttention ();

			if (l.Type == AirVPN.Core.Engine.LogType.Fatal)
				GuiUtils.MessageBox (msg);
		}