Example #1
0
 void DumpLog(LogChunk logChain)
 {
     if (context != null)
     {
         context.Post(o => {
             while (logChain != null)
             {
                 if (logChain.IsError)
                 {
                     DoWriteErrorLog(logChain.Log.ToString());
                 }
                 else
                 {
                     DoWriteLog(logChain.Log.ToString());
                 }
                 logChain = logChain.Next;
             }
         }, null);
     }
     else
     {
         while (logChain != null)
         {
             if (logChain.IsError)
             {
                 DoWriteErrorLog(logChain.Log.ToString());
             }
             else
             {
                 DoWriteLog(logChain.Log.ToString());
             }
             logChain = logChain.Next;
         }
     }
 }
Example #2
0
        public void Send(LogChunk chunk)
        {
            //this is the correct way to get current thread ID in Android
             int androidThreadId = Thread.CurrentThread.ManagedThreadId;

             string message = $"{androidThreadId}|{chunk.SourceName}|{chunk.Message}";
             if(chunk.Error != null) message += $":{chunk.Error}";

             Log.WriteLine(ToLogPriority(chunk.Severity), _appName, message);
        }
Example #3
0
 void DumpLog(LogChunk logChain)
 {
     if (context != null)
     {
         context.Post(o => {
             while (logChain != null)
             {
                 if (logChain is ObjectLogChunk objectLogChain)
                 {
                     DoWriteLogObject(objectLogChain.Object);
                 }
                 else
                 {
                     var stringLogChunk = logChain as StringLogChunk;
                     if (stringLogChunk.IsError)
                     {
                         DoWriteErrorLog(stringLogChunk.Log.ToString());
                     }
                     else
                     {
                         DoWriteLog(stringLogChunk.Log.ToString());
                     }
                 }
                 logChain = logChain.Next;
             }
         }, null);
     }
     else
     {
         while (logChain != null)
         {
             if (logChain is ObjectLogChunk objectLogChain)
             {
                 DoWriteLogObject(objectLogChain.Object);
             }
             else
             {
                 var stringLogChunk = logChain as StringLogChunk;
                 if (stringLogChunk.IsError)
                 {
                     DoWriteErrorLog(stringLogChunk.Log.ToString());
                 }
                 else
                 {
                     DoWriteLog(stringLogChunk.Log.ToString());
                 }
             }
             logChain = logChain.Next;
         }
     }
 }
Example #4
0
        public void Send(LogChunk chunk)
        {
            //this is the correct way to get current thread ID in Android
            int androidThreadId = Thread.CurrentThread.ManagedThreadId;

            string message = $"{androidThreadId}|{chunk.SourceName}|{chunk.Message}";

            if (chunk.Error != null)
            {
                message += $":{chunk.Error}";
            }

            Log.WriteLine(ToLogPriority(chunk.Severity), _appName, message);
        }
Example #5
0
        protected virtual void OnDispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }
            disposed = true;

            if (parentMonitor != null && firstCachedLogChunk != null)
            {
                parentMonitor.DumpLog(firstCachedLogChunk);
                firstCachedLogChunk = null;
            }

            var t = parentRootTask;

            parentRootTask = null;
            while (currentTask != t && currentTask != null)
            {
                EndTask();
            }

            if (context != null)
            {
                context.Post((o) => ((ProgressMonitor)o).OnCompleted(), this);
            }
            else
            {
                OnCompleted();
            }

            if (followerMonitors != null)
            {
                foreach (var m in followerMonitors)
                {
                    m.Dispose();
                }
            }
            if (disposeCallbacks != null)
            {
                foreach (var c in disposeCallbacks.ToArray())
                {
                    c();
                }
                disposeCallbacks = null;
            }
        }
Example #6
0
        public virtual void Dispose()
        {
            if (disposed)
            {
                return;
            }
            disposed = true;

            if (parentMonitor != null && firstCachedLogChunk != null)
            {
                parentMonitor.DumpLog(firstCachedLogChunk);
                firstCachedLogChunk = null;
            }

            var t = parentRootTask;

            parentRootTask = null;
            while (currentTask != t && currentTask != null)
            {
                EndTask();
            }

            if (context != null)
            {
                context.Post((o) => OnCompleted(), null);
            }
            else
            {
                OnCompleted();
            }

            if (slaveMonitors != null)
            {
                foreach (var m in slaveMonitors)
                {
                    m.Dispose();
                }
            }
            if (disposeCallbacks != null)
            {
                foreach (var c in disposeCallbacks.ToArray())
                {
                    c();
                }
                disposeCallbacks = null;
            }
        }
Example #7
0
 void AppendLogObject(object logObject)
 {
     if (firstCachedLogChunk == null)
     {
         firstCachedLogChunk = lastCachedLogChunk = new ObjectLogChunk {
             Object = logObject
         }
     }
     ;
     else
     {
         var newChunk = new ObjectLogChunk {
             Object = logObject
         };
         lastCachedLogChunk.Next = newChunk;
         lastCachedLogChunk      = newChunk;
     }
 }
Example #8
0
 void AppendLog(string message, bool error)
 {
     if (firstCachedLogChunk == null)
     {
         firstCachedLogChunk = lastCachedLogChunk = new StringLogChunk {
             IsError = error
         }
     }
     ;
     else if ((lastCachedLogChunk as StringLogChunk)?.IsError != error)
     {
         var newChunk = new StringLogChunk {
             IsError = error
         };
         lastCachedLogChunk.Next = newChunk;
         lastCachedLogChunk      = newChunk;
     }
     ((StringLogChunk)lastCachedLogChunk).Log.Append(message);
 }
Example #9
0
        void DumpLog(LogChunk logChain)
        {
            if (context != null)
            {
                context.Post(o => {
                    var(mon, chain) = (ValueTuple <ProgressMonitor, LogChunk>)o;
                    MonitorDumpLog(mon, chain);
                }, (this, logChain));
            }
            else
            {
                MonitorDumpLog(this, logChain);
            }

            void MonitorDumpLog(ProgressMonitor mon, LogChunk chain)
            {
                while (chain != null)
                {
                    if (chain is ObjectLogChunk objectLogChain)
                    {
                        mon.DoWriteLogObject(objectLogChain.Object);
                    }
                    else
                    {
                        var stringLogChunk = chain as StringLogChunk;
                        if (stringLogChunk.IsError)
                        {
                            mon.DoWriteErrorLog(stringLogChunk.Log.ToString());
                        }
                        else
                        {
                            mon.DoWriteLog(stringLogChunk.Log.ToString());
                        }
                    }
                    chain = chain.Next;
                }
            }
        }
		void AppendLog (string message, bool error)
		{
			if (firstCachedLogChunk == null)
				firstCachedLogChunk = lastCachedLogChunk = new LogChunk { IsError = error };
			else if (lastCachedLogChunk.IsError != error) {
				var newChunk = new LogChunk { IsError = error };
				lastCachedLogChunk.Next = newChunk;
				lastCachedLogChunk = newChunk;
			}
			lastCachedLogChunk.Log.Append (message);
        }
		void DumpLog (LogChunk logChain)
		{
			if (context != null)
				context.Post (o => {
					while (logChain != null) {
						if (logChain.IsError)
							DoWriteErrorLog (logChain.Log.ToString ());
						else
							DoWriteLog (logChain.Log.ToString ());
						logChain = logChain.Next;
					}
				}, null);
			else {
				while (logChain != null) {
					if (logChain.IsError)
						DoWriteErrorLog (logChain.Log.ToString ());
					else
						DoWriteLog (logChain.Log.ToString ());
					logChain = logChain.Next;
				}
            }
        }
		public virtual void Dispose ()
		{
			if (disposed)
				return;
			disposed = true;

			if (parentMonitor != null && firstCachedLogChunk != null) {
				parentMonitor.DumpLog (firstCachedLogChunk);
				firstCachedLogChunk = null;
			}

			var t = parentRootTask;
			parentRootTask = null;
			while (currentTask != t && currentTask != null)
				EndTask ();

			if (context != null)
				context.Post ((o) => OnCompleted (), null);
			else
				OnCompleted ();

			if (followerMonitors != null) {
				foreach (var m in followerMonitors)
					m.Dispose ();
			}
			if (disposeCallbacks != null) {
				foreach (var c in disposeCallbacks.ToArray ())
					c ();
				disposeCallbacks = null;
			}
		}