Click here to Skip to main content
15,893,814 members
Articles / Desktop Programming / Windows Forms

Clog: Client Logging, WPF Edition

Rate me:
Please Sign up or sign in to vote.
4.51/5 (68 votes)
25 Dec 2008LGPL312 min read 156K   964   114  
A customizable log provider system that allows you to harness your existing logging system to log client side messages to your server using WCF. Includes WPF sample applications.
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1378
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Orpius.Logging.ClogServiceReference {
    using System.Runtime.Serialization;
    using System;
    
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="ClientInfo", Namespace="http://schemas.datacontract.org/2004/07/Orpius.Logging")]
    [System.SerializableAttribute()]
    [System.Runtime.Serialization.KnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.LogEntryData))]
    public partial class ClientInfo : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
        
        [System.NonSerializedAttribute()]
        private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string IPAddressField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string LogNameField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string MachineNameField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string UrlField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string UserNameField;
        
        [global::System.ComponentModel.BrowsableAttribute(false)]
        public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
            get {
                return this.extensionDataField;
            }
            set {
                this.extensionDataField = value;
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string IPAddress {
            get {
                return this.IPAddressField;
            }
            set {
                if ((object.ReferenceEquals(this.IPAddressField, value) != true)) {
                    this.IPAddressField = value;
                    this.RaisePropertyChanged("IPAddress");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string LogName {
            get {
                return this.LogNameField;
            }
            set {
                if ((object.ReferenceEquals(this.LogNameField, value) != true)) {
                    this.LogNameField = value;
                    this.RaisePropertyChanged("LogName");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string MachineName {
            get {
                return this.MachineNameField;
            }
            set {
                if ((object.ReferenceEquals(this.MachineNameField, value) != true)) {
                    this.MachineNameField = value;
                    this.RaisePropertyChanged("MachineName");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Url {
            get {
                return this.UrlField;
            }
            set {
                if ((object.ReferenceEquals(this.UrlField, value) != true)) {
                    this.UrlField = value;
                    this.RaisePropertyChanged("Url");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string UserName {
            get {
                return this.UserNameField;
            }
            set {
                if ((object.ReferenceEquals(this.UserNameField, value) != true)) {
                    this.UserNameField = value;
                    this.RaisePropertyChanged("UserName");
                }
            }
        }
        
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        
        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="LogEntryData", Namespace="http://schemas.datacontract.org/2004/07/Orpius.Logging.LogEntries")]
    [System.SerializableAttribute()]
    public partial class LogEntryData : Orpius.Logging.ClogServiceReference.ClientInfo {
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private Orpius.Logging.ClogServiceReference.CodeLocation CodeLocationField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private Orpius.Logging.ClogServiceReference.ExceptionMemento ExceptionMementoField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private Orpius.Logging.ClogServiceReference.LogLevel LogLevelField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private int ManagedThreadIdField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string MessageField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private System.DateTime OccuredAtField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string ThreadNameField;
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public Orpius.Logging.ClogServiceReference.CodeLocation CodeLocation {
            get {
                return this.CodeLocationField;
            }
            set {
                if ((object.ReferenceEquals(this.CodeLocationField, value) != true)) {
                    this.CodeLocationField = value;
                    this.RaisePropertyChanged("CodeLocation");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public Orpius.Logging.ClogServiceReference.ExceptionMemento ExceptionMemento {
            get {
                return this.ExceptionMementoField;
            }
            set {
                if ((object.ReferenceEquals(this.ExceptionMementoField, value) != true)) {
                    this.ExceptionMementoField = value;
                    this.RaisePropertyChanged("ExceptionMemento");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public Orpius.Logging.ClogServiceReference.LogLevel LogLevel {
            get {
                return this.LogLevelField;
            }
            set {
                if ((this.LogLevelField.Equals(value) != true)) {
                    this.LogLevelField = value;
                    this.RaisePropertyChanged("LogLevel");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int ManagedThreadId {
            get {
                return this.ManagedThreadIdField;
            }
            set {
                if ((this.ManagedThreadIdField.Equals(value) != true)) {
                    this.ManagedThreadIdField = value;
                    this.RaisePropertyChanged("ManagedThreadId");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Message {
            get {
                return this.MessageField;
            }
            set {
                if ((object.ReferenceEquals(this.MessageField, value) != true)) {
                    this.MessageField = value;
                    this.RaisePropertyChanged("Message");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public System.DateTime OccuredAt {
            get {
                return this.OccuredAtField;
            }
            set {
                if ((this.OccuredAtField.Equals(value) != true)) {
                    this.OccuredAtField = value;
                    this.RaisePropertyChanged("OccuredAt");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string ThreadName {
            get {
                return this.ThreadNameField;
            }
            set {
                if ((object.ReferenceEquals(this.ThreadNameField, value) != true)) {
                    this.ThreadNameField = value;
                    this.RaisePropertyChanged("ThreadName");
                }
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="CodeLocation", Namespace="http://schemas.datacontract.org/2004/07/Orpius.Logging")]
    [System.SerializableAttribute()]
    public partial class CodeLocation : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
        
        [System.NonSerializedAttribute()]
        private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string ClassNameField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string FileNameField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private int LineNumberField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string MethodNameField;
        
        [global::System.ComponentModel.BrowsableAttribute(false)]
        public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
            get {
                return this.extensionDataField;
            }
            set {
                this.extensionDataField = value;
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string ClassName {
            get {
                return this.ClassNameField;
            }
            set {
                if ((object.ReferenceEquals(this.ClassNameField, value) != true)) {
                    this.ClassNameField = value;
                    this.RaisePropertyChanged("ClassName");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string FileName {
            get {
                return this.FileNameField;
            }
            set {
                if ((object.ReferenceEquals(this.FileNameField, value) != true)) {
                    this.FileNameField = value;
                    this.RaisePropertyChanged("FileName");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int LineNumber {
            get {
                return this.LineNumberField;
            }
            set {
                if ((this.LineNumberField.Equals(value) != true)) {
                    this.LineNumberField = value;
                    this.RaisePropertyChanged("LineNumber");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string MethodName {
            get {
                return this.MethodNameField;
            }
            set {
                if ((object.ReferenceEquals(this.MethodNameField, value) != true)) {
                    this.MethodNameField = value;
                    this.RaisePropertyChanged("MethodName");
                }
            }
        }
        
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        
        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="ExceptionMemento", Namespace="http://schemas.datacontract.org/2004/07/Orpius.Logging")]
    [System.SerializableAttribute()]
    public partial class ExceptionMemento : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
        
        [System.NonSerializedAttribute()]
        private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string HelpLinkField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string MessageField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string SourceField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string StackTraceField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string TypeNameField;
        
        [global::System.ComponentModel.BrowsableAttribute(false)]
        public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
            get {
                return this.extensionDataField;
            }
            set {
                this.extensionDataField = value;
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string HelpLink {
            get {
                return this.HelpLinkField;
            }
            set {
                if ((object.ReferenceEquals(this.HelpLinkField, value) != true)) {
                    this.HelpLinkField = value;
                    this.RaisePropertyChanged("HelpLink");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Message {
            get {
                return this.MessageField;
            }
            set {
                if ((object.ReferenceEquals(this.MessageField, value) != true)) {
                    this.MessageField = value;
                    this.RaisePropertyChanged("Message");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Source {
            get {
                return this.SourceField;
            }
            set {
                if ((object.ReferenceEquals(this.SourceField, value) != true)) {
                    this.SourceField = value;
                    this.RaisePropertyChanged("Source");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string StackTrace {
            get {
                return this.StackTraceField;
            }
            set {
                if ((object.ReferenceEquals(this.StackTraceField, value) != true)) {
                    this.StackTraceField = value;
                    this.RaisePropertyChanged("StackTrace");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string TypeName {
            get {
                return this.TypeNameField;
            }
            set {
                if ((object.ReferenceEquals(this.TypeNameField, value) != true)) {
                    this.TypeNameField = value;
                    this.RaisePropertyChanged("TypeName");
                }
            }
        }
        
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        
        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="LogLevel", Namespace="http://schemas.datacontract.org/2004/07/Orpius.Logging")]
    public enum LogLevel : int {
        
        [System.Runtime.Serialization.EnumMemberAttribute()]
        All = 0,
        
        [System.Runtime.Serialization.EnumMemberAttribute()]
        Debug = 1,
        
        [System.Runtime.Serialization.EnumMemberAttribute()]
        Info = 2,
        
        [System.Runtime.Serialization.EnumMemberAttribute()]
        Warn = 3,
        
        [System.Runtime.Serialization.EnumMemberAttribute()]
        Error = 4,
        
        [System.Runtime.Serialization.EnumMemberAttribute()]
        Fatal = 5,
        
        [System.Runtime.Serialization.EnumMemberAttribute()]
        None = 6,
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="ClientConfigurationData", Namespace="http://schemas.datacontract.org/2004/07/Orpius.Logging")]
    [System.SerializableAttribute()]
    public partial class ClientConfigurationData : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
        
        [System.NonSerializedAttribute()]
        private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private int ExpiresInSecondsField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private bool LogEnabledField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private int LogLevelField;
        
        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private System.DateTime RetrievedOnField;
        
        [global::System.ComponentModel.BrowsableAttribute(false)]
        public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
            get {
                return this.extensionDataField;
            }
            set {
                this.extensionDataField = value;
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int ExpiresInSeconds {
            get {
                return this.ExpiresInSecondsField;
            }
            set {
                if ((this.ExpiresInSecondsField.Equals(value) != true)) {
                    this.ExpiresInSecondsField = value;
                    this.RaisePropertyChanged("ExpiresInSeconds");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public bool LogEnabled {
            get {
                return this.LogEnabledField;
            }
            set {
                if ((this.LogEnabledField.Equals(value) != true)) {
                    this.LogEnabledField = value;
                    this.RaisePropertyChanged("LogEnabled");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int LogLevel {
            get {
                return this.LogLevelField;
            }
            set {
                if ((this.LogLevelField.Equals(value) != true)) {
                    this.LogLevelField = value;
                    this.RaisePropertyChanged("LogLevel");
                }
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public System.DateTime RetrievedOn {
            get {
                return this.RetrievedOnField;
            }
            set {
                if ((this.RetrievedOnField.Equals(value) != true)) {
                    this.RetrievedOnField = value;
                    this.RaisePropertyChanged("RetrievedOn");
                }
            }
        }
        
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        
        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(ConfigurationName="ClogServiceReference.IClogService")]
    public interface IClogService {
        
        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IClogService/GetConfiguration", ReplyAction="http://tempuri.org/IClogService/GetConfigurationResponse")]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.LogEntryData))]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.ClientInfo))]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.ClientConfigurationData))]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.CodeLocation))]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.ExceptionMemento))]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.LogLevel))]
        Orpius.Logging.ClogServiceReference.ClientConfigurationData GetConfiguration(object clientInfo);
        
        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IClogService/WriteEntry")]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.LogEntryData))]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.ClientInfo))]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.ClientConfigurationData))]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.CodeLocation))]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.ExceptionMemento))]
        [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Orpius.Logging.ClogServiceReference.LogLevel))]
        void WriteEntry(object entryData);
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public interface IClogServiceChannel : Orpius.Logging.ClogServiceReference.IClogService, System.ServiceModel.IClientChannel {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class ClogServiceClient : System.ServiceModel.ClientBase<Orpius.Logging.ClogServiceReference.IClogService>, Orpius.Logging.ClogServiceReference.IClogService {
        
        public ClogServiceClient() {
        }
        
        public ClogServiceClient(string endpointConfigurationName) : 
                base(endpointConfigurationName) {
        }
        
        public ClogServiceClient(string endpointConfigurationName, string remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public ClogServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public ClogServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress) {
        }
        
        public Orpius.Logging.ClogServiceReference.ClientConfigurationData GetConfiguration(object clientInfo) {
            return base.Channel.GetConfiguration(clientInfo);
        }
        
        public void WriteEntry(object entryData) {
            base.Channel.WriteEntry(entryData);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Engineer
Switzerland Switzerland
Daniel is a former senior engineer in Technology and Research at the Office of the CTO at Microsoft, working on next generation systems.

Previously Daniel was a nine-time Microsoft MVP and co-founder of Outcoder, a Swiss software and consulting company.

Daniel is the author of Windows Phone 8 Unleashed and Windows Phone 7.5 Unleashed, both published by SAMS.

Daniel is the developer behind several acclaimed mobile apps including Surfy Browser for Android and Windows Phone. Daniel is the creator of a number of popular open-source projects, most notably Codon.

Would you like Daniel to bring value to your organisation? Please contact

Blog | Twitter


Xamarin Experts
Windows 10 Experts

Comments and Discussions