Exemple #1
0
        /// <summary>
        /// Logs an entry to the logger, and any listeners are notified of the entry.
        /// </summary>
        /// <param name="entry">The text element of the log itself.</param>
        /// <param name="show">Whether or not it should be dislpayed to the user.</param>
        public static void Log(string entry, bool show = false)
        {
            UnityEngine.UnityLogWriter.WriteStringToUnityLog($"BEPIN - {entry}\r\n");

            Console.WriteLine(entry);

            EntryLogged?.Invoke(entry, show);
        }
Exemple #2
0
        /// <summary>
        /// Logs an entry to the logger, and any listeners are notified of the entry.
        /// </summary>
        /// <param name="entry">The text element of the log itself.</param>
        /// <param name="show">Whether or not it should be dislpayed to the user.</param>
        /// <param name="color">The color of the text to show in the console.</param>
        public static void Log(string entry, bool show, ConsoleColor color)
        {
            UnityEngine.UnityLogWriter.WriteStringToUnityLog($"BEPIN - {entry}\r\n");

            Kon.ForegroundColor = color;
            Console.WriteLine(entry);

            EntryLogged?.Invoke(entry, show);
        }
Exemple #3
0
 /// <summary>
 /// Logs an entry to the Logger instance.
 /// </summary>
 /// <param name="level">The level of the entry.</param>
 /// <param name="entry">The textual value of the entry.</param>
 public virtual void Log(LogLevel level, object entry)
 {
     if ((DisplayedLevels & level) != LogLevel.None)
     {
         lock (logLockObj)
         {
             EntryLogged?.Invoke(level, entry);
             WriteLine($"[{level.GetHighestLevel()}] {entry}");
         }
     }
 }
        private void Update(object sender, ElapsedEventArgs e)
        {
            var allProcesses = Process.GetProcesses();

            Watchers.ToList().ForEach(w => w.Update(allProcesses));

            var tempDurations = new Dictionary <string, TimeSpan>(Durations);

            // This is necessary to avoid two or more processes with the same name adding to duration twice
            var tempUpdatedTempDurations = new HashSet <string>();

            foreach (var proc in WatchedProcesses)
            {
                string name = proc.Key.Item1;

                if (tempDurations.ContainsKey(name) && !tempUpdatedTempDurations.Contains(name))
                {
                    tempDurations[name] += proc.Value.Elapsed;
                    tempUpdatedTempDurations.Add(name);
                }
            }

            if (WatchedProcesses.Count > 0 && !TotalTime.IsRunning)
            {
                TotalTime.Start();
            }
            else if (WatchedProcesses.Count == 0 && TotalTime.IsRunning)
            {
                TotalTime.Stop();
            }

            var durationsList = new HashSet <Tuple <bool, string> >();

            foreach (var duration in tempDurations.OrderByDescending(d => d.Value))
            {
                durationsList.Add(new Tuple <bool, string>(WatchedProcesses.Any(p => p.Key.Item1.StartsWith(duration.Key)),
                                                           $"{duration.Value.ToString(timeFormat)}|{duration.Key}"));
            }

            var logEntry = new ProcessWatcherEventArgs()
            {
                Output    = String.Join(String.Empty, Log),
                Durations = durationsList,
                Watching  = WatchedProcesses.Count,
                TotalTime = TotalTime.Elapsed.ToString(timeFormat)
            };

            EntryLogged?.Invoke(this, logEntry);

            tempUpdatedTempDurations.Clear();
            Log.Clear();
        }
Exemple #5
0
 private static void LogEntry(string type, string text)
 {
     EntryLogged?.Invoke(type, text);
 }
Exemple #6
0
        /// <summary>
        /// Logs an entry to the current logger instance.
        /// </summary>
        /// <param name="level">The level of the entry.</param>
        /// <param name="entry">The textual value of the entry.</param>
        public static void Log(LogLevel level, object entry)
        {
            EntryLogged?.Invoke(level, entry);

            CurrentLogger?.Log(level, entry);
        }
Exemple #7
0
 public static void EntryLogger(string entry, bool show)
 {
     EntryLogged?.Invoke(entry, show);
 }
Exemple #8
0
        /// <summary>
        /// Logs an entry to the logger, and any listeners are notified of the entry.
        /// </summary>
        /// <param name="entry">The text element of the log itself.</param>
        /// <param name="show">Whether or not it should be dislpayed to the user.</param>
        public static void Log(string entry, bool show = false)
        {
            Logger.Log(show ? LogLevel.Message : LogLevel.Info, entry);

            EntryLogged?.Invoke(entry, show);
        }