Exemple #1
0
        public void LogInternal(APILogItem logItem)
        {
            using (StreamWriter w = File.AppendText(getFileName(logItem.LoggingTime)))
            {
                w.WriteLine(logItem.LoggingTime.ToString("MM/dd/yyyy hh:mm:ss.fff tt") + "\t" + logItem.Signature);
                if (logItem.NoOfKeys > 1)
                {
                    w.WriteLine(String.Format("{0,-30}\t Number of Keys = {1}", "", logItem.NoOfKeys.ToString()));
                }

                if (!String.IsNullOrEmpty(logItem.Key))
                {
                    w.WriteLine(String.Format("{0,-30}\t Key = {1}", " ", logItem.Key));
                }

                if (logItem.AbsolueExpiration != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Absolute Expiration = {1}", " ", logItem.AbsolueExpiration.ToString()));
                }
                if (logItem.SlidingExpiration != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Sliding Expiration = {1} milliseconds", " ", logItem.SlidingExpiration.Value.TotalMilliseconds));
                }

                if (!String.IsNullOrEmpty(logItem.Group))
                {
                    w.WriteLine(String.Format("{0,-30}\t Group = {1}", " ", logItem.Group));
                }
                if (!String.IsNullOrEmpty(logItem.SubGroup))
                {
                    w.WriteLine(String.Format("{0,-30}\t SubGroup = {1}", " ", logItem.SubGroup));
                }

                if (logItem.Tags != null && logItem.Tags.Length != 0)
                {
                    w.WriteLine(String.Format("{0,-30}\t Tags:", " "));
                    foreach (Tag t in logItem.Tags)
                    {
                        w.WriteLine(String.Format("{0,-30}\t\tValue = {1}", " ", t != null ? t.TagName : ""));
                    }
                }

                if (logItem.NamedTags != null && logItem.NamedTags.Count != 0)
                {
                    w.WriteLine(String.Format("{0,-30}\t NamedTags:", " "));
                    IEnumerator ie = logItem.NamedTags.GetEnumerator();
                    while (ie.MoveNext())
                    {
                        DictionaryEntry de = (DictionaryEntry)ie.Current;
                        w.WriteLine(String.Format("{0,-30}\t\t Key = " + de.Key.ToString() + "\tValue = " + de.Value.ToString(), " "));
                    }
                }

                if (logItem.Priority != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Priority = {1}", " ", logItem.Priority.ToString()));
                }

                if (logItem.Dependency != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Dependency = {1}", " ", logItem.Dependency.GetType().Name));
                    if ((logItem.Dependency as Runtime.Dependencies.KeyDependency) != null)
                    {
                        w.WriteLine(string.Format("{0,-30}\t\t KeyDependencyType = {1}", " ", (logItem.Dependency as Runtime.Dependencies.KeyDependency).KeyDependencyType));
                        w.WriteLine(String.Format("{0,-30}\t\t Keys:", " "));
                        Runtime.Dependencies.KeyDependency kd = (Runtime.Dependencies.KeyDependency)logItem.Dependency;
                        foreach (string key in kd.CacheKeys)
                        {
                            w.WriteLine(String.Format("{0,-30}\t\t\tValue = {1}", " ", key));
                        }
                    }
                    else if ((logItem.Dependency as Runtime.Dependencies.FileDependency) != null)
                    {
                        w.WriteLine(String.Format("{0,-30}\t\t Files:", " "));
                        Runtime.Dependencies.FileDependency fd = (Runtime.Dependencies.FileDependency)logItem.Dependency;
                        foreach (string fileName in fd.fileNames)
                        {
                            w.WriteLine(String.Format("{0,-30}\t\t\tValue = {1}", " ", fileName));
                        }
                    }
                }
                if (logItem.SyncDependency != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t SyncDependency = {1}", " ", logItem.SyncDependency.ToString()));
                }
                if (logItem.IsResyncRequired != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t IsResyncRequired = {1}", " ", logItem.IsResyncRequired.ToString()));
                }


                if (!String.IsNullOrEmpty(logItem.ProviderName))
                {
                    w.WriteLine(String.Format("{0,-30}\t ProviderName = {1}", " ", logItem.ProviderName));
                }

                if (!String.IsNullOrEmpty(logItem.ResyncProviderName))
                {
                    w.WriteLine(String.Format("{0,-30}\t ResyncProviderName = {1}", " ", logItem.ResyncProviderName));
                }

                if (logItem.DSWriteOption != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t DSWriteOption = {1}", " ", logItem.DSWriteOption.ToString()));
                }

                if (logItem.DSReadOption != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t DSReadOption = {1}", " ", logItem.DSReadOption.ToString()));
                }


                if (logItem.ContinuousQuery != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t ContinuousQuery:", " "));
                    w.WriteLine(String.Format("{0,-30}\t\t Query = {1}", " ", logItem.ContinuousQuery.Query));
                    w.WriteLine(String.Format("{0,-30}\t\t Values:", " "));
                    IDictionaryEnumerator ide = logItem.ContinuousQuery.Values.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        w.WriteLine(String.Format("{0,-30}\t\t\t Key = " + ide.Key.ToString() + "\tValue = " + ide.Value.ToString(), " "));
                    }
                }


                if (!string.IsNullOrEmpty(logItem.Query))
                {
                    w.WriteLine(String.Format("{0,-30}\t Query = {1}", " ", logItem.Query.ToString()));
                }
                if (logItem.QueryValues != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Values:", " "));
                    IDictionaryEnumerator ide = logItem.QueryValues.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        w.WriteLine(String.Format("{0,-30}\t\t Key = " + ide.Key.ToString() + "\tValue = " + ide.Value.ToString(), " "));
                    }
                }

                if (logItem.LockTimeout != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t LockTimeout = {1} milliseconds", " ", logItem.LockTimeout.Value.TotalMilliseconds.ToString()));
                }
                if (logItem.AcquireLock != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t AcquireLock = {1}", " ", logItem.AcquireLock.ToString()));
                }


                if (logItem.StreamMode != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t SreamMode = {1}", " ", logItem.StreamMode.ToString()));
                }

                if (logItem.CacheItemVersion != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t CacheItemVersion = {1}", " ", logItem.CacheItemVersion.ToString()));
                }

                if (logItem.RuntimeAPILogItem != null)
                {
                    RuntimeAPILogItem rtLogItem = logItem.RuntimeAPILogItem;
                    string            avg       = rtLogItem.IsBulk ? "Average " : "";
                    if (rtLogItem.IsBulk)
                    {
                        w.WriteLine(String.Format("{0,-30}\t Number of Objects = {1}", " ", rtLogItem.NoOfObjects.ToString()));
                    }
                    w.WriteLine(String.Format("{0,-30}\t {1}Object Size (bytes) = {2}", " ", avg, rtLogItem.SizeOfObject));
                    w.WriteLine(String.Format("{0,-30}\t Encryption Enabled = {1}", " ", rtLogItem.EncryptionEnabled.ToString()));
                    if (rtLogItem.EncryptionEnabled)
                    {
                        w.WriteLine(String.Format("{0,-30}\t {1}Encrypted Object Size (bytes) = {2}", " ", avg, logItem.RuntimeAPILogItem.SizeOfEncryptedObject));
                    }
                    w.WriteLine(String.Format("{0,-30}\t Compression Enabled = {1}", " ", rtLogItem.CompressionEnabled.ToString()));
                    if (rtLogItem.CompressionEnabled)
                    {
                        w.WriteLine(String.Format("{0,-30}\t {1}Compressed Object Size (bytes) = {2}", " ", avg, logItem.RuntimeAPILogItem.SizeOfCompressedObject));
                    }
                }

                if (logItem.NoOfObjectsReturned != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Number of Objects Returned = {1}", " ", logItem.NoOfObjectsReturned.ToString()));
                }
                if (logItem.ExceptionMessage != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Exception = {1}", " ", logItem.ExceptionMessage));
                }
                w.WriteLine();
            }
        }
Exemple #2
0
 /// <summary>
 /// Adds Size info to hashtable for logging
 /// </summary>
 /// <param name="isBulk"></param>
 /// <param name="objectSize">Size of Object after serialization. Incase of Bulk, it will be the sum of size of objects.</param>
 /// <param name="noOfObjects"></param>
 private void LogSizeInfo(bool isBulk, long objectSize, int noOfObjects)
 {
     Web.Caching.APILogging.RuntimeAPILogItem rtAPILogItem = new Web.Caching.APILogging.RuntimeAPILogItem();
     rtAPILogItem.IsBulk = isBulk;
     rtAPILogItem.NoOfObjects = noOfObjects;
     if (noOfObjects != 0)
     {
         rtAPILogItem.SizeOfObject = objectSize / noOfObjects;
     }
     APILogHashTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = rtAPILogItem;
 }
Exemple #3
0
        public void LogInternal(APILogItem logItem)
        {
            using (StreamWriter w = File.AppendText(getFileName(logItem.LoggingTime)))
            {
                w.WriteLine(logItem.LoggingTime.ToString("MM/dd/yyyy hh:mm:ss.fff tt") + "\t" + logItem.Signature);
                if (logItem.NoOfKeys > 1)
                {
                    w.WriteLine(String.Format("{0,-30}\t Number of Keys = {1}", "", logItem.NoOfKeys.ToString()));
                }

                if (!String.IsNullOrEmpty(logItem.Key))
                {
                    w.WriteLine(String.Format("{0,-30}\t Key = {1}", " ", logItem.Key));
                }
                if (logItem.AbsolueExpiration != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Absolute Expiration = {1}", " ", logItem.AbsolueExpiration.ToString()));
                }
                if (logItem.SlidingExpiration != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Sliding Expiration = {1} milliseconds", " ", logItem.SlidingExpiration.Value.TotalMilliseconds));
                }
                if (logItem.Priority != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Priority = {1}", " ", logItem.Priority.ToString()));
                }

                if (!string.IsNullOrEmpty(logItem.Query))
                {
                    w.WriteLine(String.Format("{0,-30}\t Query = {1}", " ", logItem.Query.ToString()));
                }

                if (logItem.QueryValues != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Values:", " "));
                    IDictionaryEnumerator ide = logItem.QueryValues.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        w.WriteLine(String.Format("{0,-30}\t\t Key = " + ide.Key.ToString() + "\tValue = " + ide.Value.ToString(), " "));
                    }
                }

                if (logItem.LockTimeout != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t LockTimeout = {1} milliseconds", " ", logItem.LockTimeout.Value.TotalMilliseconds.ToString()));
                }
                if (logItem.AcquireLock != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t AcquireLock = {1}", " ", logItem.AcquireLock.ToString()));
                }

                if (logItem.RuntimeAPILogItem != null)
                {
                    RuntimeAPILogItem rtLogItem = logItem.RuntimeAPILogItem;
                    string            avg       = rtLogItem.IsBulk ? "Average " : "";
                    if (rtLogItem.IsBulk)
                    {
                        w.WriteLine(String.Format("{0,-30}\t Number of Objects = {1}", " ", rtLogItem.NoOfObjects.ToString()));
                    }
                    w.WriteLine(String.Format("{0,-30}\t {1}Object Size (bytes) = {2}", " ", avg, rtLogItem.SizeOfObject));
                }

                if (logItem.NoOfObjectsReturned != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Number of Objects Returned = {1}", " ", logItem.NoOfObjectsReturned.ToString()));
                }
                if (logItem.ExceptionMessage != null)
                {
                    w.WriteLine(String.Format("{0,-30}\t Exception = {1}", " ", logItem.ExceptionMessage));
                }
                w.WriteLine();
            }
        }