Beispiel #1
0
        /// <summary>
        /// Zaloguje spravu do SQLite databazy asynchronnym volanim
        /// </summary>
        /// <exception cref="ObjectDisposedException">
        /// Ak je object v stave _disposed
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Argument nie je inicializovany
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Ak klient nie je v stave Start
        /// </exception>
        /// <param name="time">Cas vzniku logovacej spravy</param>
        /// <param name="_traceType">Typ logovacej spravy</param>
        /// <param name="modulName">Meno modulu ktory spravy vytvoril</param>
        /// <param name="message">Text logovacej spravy</param>
        public void TraceAsync(DateTime time, TraceTypes traceType, String modulName, String message)
        {
            //je objekt _disposed ?
            if (this.IsDisposed)
            {
                throw new ObjectDisposedException("Object was disposed");
            }

            //klient musi byt spusteny aby sa dalo logovat
            if (this.ClientState != ClientStates.Start)
            {
                throw new InvalidOperationException(String.Format("'{0}' is not running.", this));
            }

            //overime vstupne data
            if (String.IsNullOrEmpty(modulName))
            {
                throw new ArgumentNullException("modulName");
            }
            if (String.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("message");
            }

            //pomocny delegat
            TraceAsyncDelegate asyncDelegate = new TraceAsyncDelegate(this.AddTraceItem);

            asyncDelegate.BeginInvoke(time, traceType, modulName, message, null, null);
        }
Beispiel #2
0
        /// <summary>
        /// Zaloguje spravu do SQLite databazy
        /// </summary>
        /// <exception cref="ObjectDisposedException">
        /// Ak je object v stave _disposed
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Argument nie je inicializovany
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Ak klient nie je v stave Start
        /// </exception>
        /// <param name="time">Cas vzniku logovacej spravy</param>
        /// <param name="_traceType">Typ logovacej spravy</param>
        /// <param name="modulName">Meno modulu ktory spravy vytvoril</param>
        /// <param name="message">Text logovacej spravy</param>
        /// <returns>
        /// True = urcuje len uspesne ulozenie zaznamu do kolekcie ktora caka na ulozenie.
        /// True este neznamena ze zaznam bol aj naozaj ulozeny.
        /// </returns>
        public bool Trace(DateTime time, TraceTypes traceType, String modulName, String message)
        {
            //je objekt _disposed ?
            if (this.IsDisposed)
            {
                throw new ObjectDisposedException("Object was disposed");
            }

            //klient musi byt spusteny aby sa dalo logovat
            if (this.ClientState != ClientStates.Start)
            {
                throw new InvalidOperationException(String.Format("'{0}' is not running.", this));
            }

            //overime vstupne data
            if (String.IsNullOrEmpty(modulName))
            {
                throw new ArgumentNullException("modulName");
            }
            if (String.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("message");
            }

            //zalogujeme spravu
            return(this.AddTraceItem(time, traceType, modulName, message));
        }
Beispiel #3
0
        /// <summary>
        /// Prida dalsi zaznam do kolekcia ktora caka na ulozenie do databazy
        /// </summary>
        /// <param name="time">Cas zaznamu</param>
        /// <param name="_traceType">Typ zaznamu</param>
        /// <param name="modulName">Meno modulu ktory zaznam vytvoril</param>
        /// <param name="message">Sprava zaznamu</param>
        /// <returns>True = zaznam bol uspesne pridany do kolekcie na ulozenie</returns>
        private Boolean AddTraceItem(DateTime time, TraceTypes traceType, String modulName, String message)
        {
            //vytvorime dalsiu strukturu zaznamu
            TraceItem item = new TraceItem(time, traceType, modulName, message);

            try
            {
                //zalogujeme aj do konzoly
                if (this._consoleTrace)
                {
                    //zalogujeme
                    Console.WriteLine(String.Format("[{0}] [{1}]: {2}", time.ToString("HH:mm:ss.fff"),
                                                    traceType, message));
                }

                //synchronizujeme pristup
                lock (this._lockObj)
                {
                    //pridame dalsi zaznam
                    this._items.Add(item);
                }

                //zaznam bol uspesne pridany
                return(true);
            }
            catch (Exception ex)
            {
                //interna chyba
                this.InternalException(ex, "Internal system error");

                //zaznam sa nepodarilo pridat
                return(false);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Initialize this class
 /// </summary>
 /// <param name="time">Cas zaznamu</param>
 /// <param name="_traceType">Typ zaznamu</param>
 /// <param name="modulName">Meno modulu ktory zaznam vytvoril</param>
 /// <param name="message">Sprava zaznamu</param>
 public TraceItem(DateTime time, TraceTypes traceType, String modulName, String message)
 {
     this._time      = time;
     this._traceType = traceType;
     this._modulName = modulName;
     this._message   = message;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public TraceEventArgs(TraceTypes type, object data, string receiver)
 {
     Timestamp = DateTime.Now;
     Type      = type;
     Data      = data;
     Receiver  = receiver;
 }
 /// <summary>
 /// Zaloguje spravu
 /// </summary>
 /// <param name="type">Typ logovania</param>
 /// <param name="message">Sprava ktoru chceme zalogovat</param>
 /// <param name="args">Argumenty pre String.Format</param>
 public static void Trace(TraceTypes type, String message, params Object[] args)
 {
     if (!String.IsNullOrWhiteSpace(message))
     {
         TraceLogger.DirectoryPath = HttpContext.Current.Server.MapPath("~/App_Data/Trace/");
         TraceLogger.Trace(DateTime.Now, type, "App", ((args != null && args.Length > 0) ? String.Format(message, args) : message));
     }
 }
 /// <summary>
 /// Creates a new SmartSwitch, initialising its level.
 /// </summary>
 /// <param name="displayName">The name of the Switch.</param>
 /// <param name="description">The description of the Switch.</param>
 /// <param name="level">The initial level of the switch.</param>
 public SmartSwitch(
     string displayName,
     string description,
     TraceTypes level)
     : base(displayName, description)
 {
     //	Store the initial level.  This will also update it in the base class.
     this.Level = (int)level;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public TraceEventArgs(TraceTypes type, byte[] data, int index, int length, string receiver)
 {
     Timestamp = DateTime.Now;
     Type      = type;
     byte[] tmp = new byte[length];
     Array.Copy(data, index, tmp, 0, length);
     Data     = tmp;
     Receiver = receiver;
 }
Beispiel #9
0
        /// <summary>
        /// Zaloguje spravu do SQLite databazy
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// Argument nie je inicializovany
        /// </exception>
        /// <param name="traceType">Typ logovacej spravy</param>
        /// <param name="message">Text logovacej spravy</param>
        /// <returns>True = logovanie spravy bolo uspesne</returns>
        public static bool Trace(TraceTypes traceType, String message)
        {
            //overime vstupne data
            if (String.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("message");
            }

            //zalogujeme spravu
            return(Trace(DateTime.Now, traceType, null, message));
        }
Beispiel #10
0
        /// <summary>
        /// Zaloguje spravu do suboru
        /// </summary>
        /// <param name="type">Trace type for log</param>
        /// <param name="message">Sprava</param>
        /// <param name="args">String.Format argumenty pre spravu</param>
        private void InternalTrace(TraceTypes type, String message, params Object[] args)
        {
            //check type
            if (type == this.TraceType || (type == TraceTypes.Error && this.TraceErrorAlways))
            {
                //update message
                message = String.Format(message, args);

                //trace
                TraceLogger.Trace(type, message);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Zaloguje spravu do SQLite databazy
        /// </summary>
        /// <exception cref="ObjectDisposedException">
        /// Ak je object v stave _disposed
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Argument nie je inicializovany
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Ak klient nie je v stave Start
        /// </exception>
        /// <param name="date">Cas vzniku logovacej spravy</param>
        /// <param name="traceType">Typ logovacej spravy</param>
        /// <param name="modulName">Meno modulu ktory spravy vytvoril</param>
        /// <param name="message">Text logovacej spravy</param>
        /// <returns>True = logovanie spravy bolo uspesne</returns>
        public static bool Trace(DateTime date, TraceTypes traceType, String modulName, String message)
        {
            //overime vstupne data
            //if (String.IsNullOrEmpty(modulName))
            //    throw new ArgumentNullException("modulName");
            if (String.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("message");
            }

            //zalogujeme spravu
            return(TraceToFile(date, traceType, modulName, message));
        }
        /// <summary>
        /// Initialize this class
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// Chybny argument typu String
        /// </exception>
        /// <param name="time">Cas a datum vzniku logovacej spravy</param>
        /// <param name="modul">Meno modulu ktory spravu vytvorill</param>
        /// <param name="traceType">Typ logovacej spravy</param>
        /// <param name="message">Sprava s informaciou</param>
        public TraceEventArgs(DateTime time, String modul, TraceTypes traceType, String message)
        {
            //osetrime vstupne parametre
            if (String.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("message");
            }

            this.time      = time;
            this.modul     = modul;
            this.traceType = traceType;
            this.message   = message;
        }
Beispiel #13
0
        /// <summary>
        /// Zaloguje spravu do SQLite databazy asynchronnym volanim
        /// </summary>
        /// <exception cref="ObjectDisposedException">
        /// Ak je object v stave _disposed
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Argument nie je inicializovany
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Ak klient nie je v stave Start
        /// </exception>
        /// <param name="date">Cas vzniku logovacej spravy</param>
        /// <param name="traceType">Typ logovacej spravy</param>
        /// <param name="modulName">Meno modulu ktory spravy vytvoril</param>
        /// <param name="message">Text logovacej spravy</param>
        public static void TraceAsync(DateTime date, TraceTypes traceType, String modulName, String message)
        {
            //overime vstupne data
            //if (String.IsNullOrEmpty(modulName))
            //    throw new ArgumentNullException("modulName");
            if (String.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("message");
            }

            //pomocny delegat
            TraceAsyncDelegate asyncDelegate = new TraceAsyncDelegate(TraceToFile);

            asyncDelegate.BeginInvoke(date, traceType, modulName, message, null, null);
        }
        /// <summary>
        /// Spracuje logovacie spravy. Ak sprava vyhovuje nastaveniam odosle ju na logovanie
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// Argument 'message' je null alebo empty
        /// </exception>
        /// <param name="time">Cas kedy sprava vznikla</param>
        /// <param name="type">Typ spravy</param>
        /// <param name="message">Text spravy</param>
        /// <param name="msgArgs">Dalsie argumenty do String.Format k sprave</param>
        protected void InternalTrace(DateTime time, TraceTypes type, String message, params Object[] msgArgs)
        {
            //osetrenie
            if (String.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("message");
            }

            //sk sprava vyhovuje jednymu z typov logovania
            if (((this._traceType & TraceTypes.Error) == type) ||
                ((this._traceType & TraceTypes.Info) == type) ||
                ((this._traceType & TraceTypes.Verbose) == type) ||
                ((this._traceType & TraceTypes.Warning) == type) ||
                (this._traceErrorAlways && type == TraceTypes.Error) ||
                (this._traceType == TraceTypes.Verbose))
            {
                //odosleme spravu na logovanie
                this.OnInternalTrace(time, type, message, msgArgs);
            }
        }
        /// <summary>
        /// Vykona logovanie spravy
        /// </summary>
        /// <param name="time">Cas kedy sprava vznikla</param>
        /// <param name="type">Typ spravy</param>
        /// <param name="message">Text spravy</param>
        /// <param name="msgArgs">Dalsie argumenty do String.Format k sprave</param>
        private void OnInternalTrace(DateTime time, TraceTypes type, String message, params Object[] msgArgs)
        {
            //ak je poziadavka na interne logovanie do suboru
            if (this._traceInternalProcess)
            {
                //len pre osetrenie
                if (this._traceClient != null)
                {
                    if (!this._traceClient.IsDisposed)
                    {
                        if (this._traceClient.IsRun)
                        {
                            //zalogujeme
                            this._traceClient.TraceAsync(time, type, this.ToString(), String.Format(message, msgArgs));
                        }
                    }
                }
            }

            //odosleme spravu
            this.OnTrace(this, new TraceEventArgs(time, this.ToString(), type, String.Format(message, msgArgs)));
        }
 /// <summary>
 /// Will output the passed message to the trace listeners if the trace switch indicates that
 /// the message type is one that can be produced.
 /// </summary>
 /// <param name="traceType">
 /// Type of trace message.
 /// </param>
 /// <param name="message">
 /// The message to send.
 /// </param>
 public void TraceMsg(TraceTypes traceType, string message)
 {
     TraceMsg((int)traceType, message);
 }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StyleCopSwitch"/> class with a specified enumerated trace level.
 /// </summary>
 /// <param name="displayName">
 /// The name of the switch.
 /// </param>
 /// <param name="description">
 /// A description of the switch.
 /// </param>
 /// <param name="level">
 /// The trace level as a combination of <see cref="TraceTypes"/> values.
 /// </param>
 public StyleCopSwitch(string displayName, string description, TraceTypes level)
     : this(displayName, description, (int)level)
 {
 }
Beispiel #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StyleCopSwitch"/> class with a specified enumerated trace level.
 /// </summary>
 /// <param name="displayName">
 /// The name of the switch.
 /// </param>
 /// <param name="description">
 /// A description of the switch.
 /// </param>
 /// <param name="level">
 /// The trace level as a combination of <see cref="TraceTypes"/> values.
 /// </param>
 public StyleCopSwitch(string displayName, string description, TraceTypes level)
     : this(displayName, description, (int)level)
 {
 }
 internal void NotifyVerbose(object sender, TraceTypes type, object data)
 {
     if (Trace == TraceLevel.Verbose && m_OnTrace != null)
     {
         m_OnTrace(sender, new TraceEventArgs(type, data, null));
     }
 }
        /// <summary>
        /// Zaloguje spravu do SQLite databazy asynchronnym volanim
        /// </summary>
        /// <exception cref="ObjectDisposedException">
        /// Ak je object v stave _disposed
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Argument nie je inicializovany
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Ak klient nie je v stave Start
        /// </exception>
        /// <param name="date">Cas vzniku logovacej spravy</param>
        /// <param name="traceType">Typ logovacej spravy</param>
        /// <param name="modulName">Meno modulu ktory spravy vytvoril</param>
        /// <param name="message">Text logovacej spravy</param>
        public static void TraceAsync(DateTime date, TraceTypes traceType, String modulName, String message)
        {
            //overime vstupne data
            //if (String.IsNullOrEmpty(modulName))
            //    throw new ArgumentNullException("modulName");
            if (String.IsNullOrEmpty(message))
                throw new ArgumentNullException("message");

            //pomocny delegat
            TraceAsyncDelegate asyncDelegate = new TraceAsyncDelegate(TraceToFile);
            asyncDelegate.BeginInvoke(date, traceType, modulName, message, null, null);
        }
        /// <summary>
        /// Zapise pozadovane data do SQLite databazy
        /// </summary>
        /// <param name="date">Cas log zaznamu</param>
        /// <param name="traceType">Typ logovacej spravy</param>
        /// <param name="modulName">Meno modulu ktory spravy vytvoril</param>
        /// <param name="message">Sprava s informaciou</param>
        /// <returns>True = zapis logu bol uspesny</returns>
        private static Boolean TraceToFile(DateTime date, TraceTypes traceType, String modulName, String message)
        {
            //zapisovac do suboru
            TextWriter textWriter = null;

            try
            {
                lock (m_lockObj)
                {
                    //ak nie je zadany folder na logovanie
                    if (String.IsNullOrWhiteSpace(TraceLogger.m_directory))
                    {
                        //vytvorime cestu k priecinku na ulozenie Trace
                        TraceLogger.m_directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "Trace";
                    }

                    //zistime ci existuje subfolder ak nie tak ho pridame...
                    if (!Directory.Exists(TraceLogger.m_directory))
                        Directory.CreateDirectory(TraceLogger.m_directory);

                    //vytvorime plnu cestu k suboru
                    String fileName = TraceLogger.m_directory + Path.DirectorySeparatorChar + DateTime.Now.Date.ToString("yyyy_MM_dd") + ".log";

                    //inicializacia
                    textWriter = TextWriter.Synchronized(File.AppendText(fileName));

                    //meno modulu
                    modulName = String.IsNullOrWhiteSpace(modulName) ? String.Empty : String.Format(" [{0}]", modulName);

                    // Create string recipients write
                    message = String.Format("{0}{1} -> {2}", traceType, modulName, message);

                    //zapiseme na konzolu
                    ConsoleLogger.WriteLine(message);

                    // Create string recipients write
                    message = String.Format("{0} {1}", date.ToString("yyyy-MM-dd HH:mm:ss.fff"), message);

                    // Write string and close file
                    textWriter.WriteLine(message);

                    //zapis logu bol uspesny
                    return true;
                }
            }
            catch (Exception ex)
            {
                //zapis do trace, netusim kde recipients pojde
                ConsoleLogger.WriteLine("Chyba pri zapise log suboru. {0}", ex);
#if DEBUG
                Debug.WriteLine(ex);
#endif
                //ukoncime s chybou
                return false;
            }
            finally
            {
                //ukoncime zapisovac
                if (textWriter != null)
                {
                    textWriter.Close();
                    textWriter.Dispose();
                }
            }
        }
 /// <summary>
 /// Create a new <see cref="Microsoft.Sdc.BizTalkOM.SmartTrace"/>.
 /// </summary>
 /// <param name="displayName">
 /// Name of the <see cref="Microsoft.Sdc.BizTalkOM.SmartSwitch"/> to use.
 /// </param>
 /// <param name="description">
 /// Description of the <see cref="Microsoft.Sdc.BizTalkOM.SmartSwitch"/> to use.
 /// </param>
 /// <param name="level">
 /// Initial <see cref="Microsoft.Sdc.BizTalkOM.TraceTypes"/> level to use.
 /// </param>
 internal SmartTrace(string displayName, string description, TraceTypes level)
     : this(displayName, description, (int)level)
 {
     logger = LoggerFactory.GetLogger();
 }
        /// <summary>
        /// Zaloguje spravu do SQLite databazy
        /// </summary>
        /// <exception cref="ObjectDisposedException">
        /// Ak je object v stave _disposed
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Argument nie je inicializovany
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Ak klient nie je v stave Start
        /// </exception>
        /// <param name="date">Cas vzniku logovacej spravy</param>
        /// <param name="traceType">Typ logovacej spravy</param>
        /// <param name="modulName">Meno modulu ktory spravy vytvoril</param>
        /// <param name="message">Text logovacej spravy</param>
        /// <returns>True = logovanie spravy bolo uspesne</returns>
        public static bool Trace(DateTime date, TraceTypes traceType, String modulName, String message)
        {
            //overime vstupne data
            //if (String.IsNullOrEmpty(modulName))
            //    throw new ArgumentNullException("modulName");
            if (String.IsNullOrEmpty(message))
                throw new ArgumentNullException("message");

            //zalogujeme spravu
            return TraceToFile(date, traceType, modulName, message);
        }
Beispiel #24
0
 /// <summary>
 /// Zaloguje pozadovanu spravu do suboru
 /// </summary>
 /// <param name="type">Typ logovania</param>
 /// <param name="message">Sprava ktoru chceme zalogovat</param>
 /// <param name="args">Argumenty pre String.Format(message, args)</param>
 public static void OnTrace(TraceTypes type, String message, params Object[] args)
 {
     WebUtility.Trace(type, message, args);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public TraceEventArgs(TraceTypes type, byte[] data, int index, int length, string receiver)
 {
     Timestamp = DateTime.Now;
     Type = type;
     byte[] tmp = new byte[length];
     Array.Copy(data, index, tmp, 0, length);
     Data = tmp;
     Receiver = receiver;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public TraceEventArgs(TraceTypes type, object data, string receiver)
 {
     Timestamp = DateTime.Now;
     Type = type;
     Data = data;
     Receiver = receiver;
 }
 /// <summary>
 /// Will output the passed message to the trace listeners if the trace switch indicates that
 /// the message type is one that can be produced.
 /// </summary>
 /// <param name="traceType">
 /// Type of trace message.
 /// </param>
 /// <param name="format">
 /// Format to be used when writing the args to a string.
 /// </param>
 /// <param name="args">
 /// The arguments to insert into the format string.
 /// </param>
 public void TraceMsg(TraceTypes traceType, string format, params object[] args)
 {
     TraceMsg((int)traceType, format, args);
 }
Beispiel #28
0
        /// <summary>
        /// Zapise pozadovane data do SQLite databazy
        /// </summary>
        /// <param name="date">Cas log zaznamu</param>
        /// <param name="traceType">Typ logovacej spravy</param>
        /// <param name="modulName">Meno modulu ktory spravy vytvoril</param>
        /// <param name="message">Sprava s informaciou</param>
        /// <returns>True = zapis logu bol uspesny</returns>
        private static Boolean TraceToFile(DateTime date, TraceTypes traceType, String modulName, String message)
        {
            //zapisovac do suboru
            TextWriter textWriter = null;

            try
            {
                lock (m_lockObj)
                {
                    //ak nie je zadany folder na logovanie
                    if (String.IsNullOrWhiteSpace(TraceLogger.m_directory))
                    {
                        //vytvorime cestu k priecinku na ulozenie Trace
                        TraceLogger.m_directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "Trace";
                    }

                    //zistime ci existuje subfolder ak nie tak ho pridame...
                    if (!Directory.Exists(TraceLogger.m_directory))
                    {
                        Directory.CreateDirectory(TraceLogger.m_directory);
                    }

                    //vytvorime plnu cestu k suboru
                    String fileName = TraceLogger.m_directory + Path.DirectorySeparatorChar + DateTime.Now.Date.ToString("yyyy_MM_dd") + ".log";

                    //inicializacia
                    textWriter = TextWriter.Synchronized(File.AppendText(fileName));

                    //meno modulu
                    modulName = String.IsNullOrWhiteSpace(modulName) ? String.Empty : String.Format(" [{0}]", modulName);

                    // Create string recipients write
                    message = String.Format("{0}{1} -> {2}", traceType, modulName, message);

                    //zapiseme na konzolu
                    ConsoleLogger.Info(message);

                    // Create string recipients write
                    message = String.Format("{0} {1}", date.ToString("yyyy-MM-dd HH:mm:ss.fff"), message);

                    // Write string and close file
                    textWriter.WriteLine(message);

                    //zapis logu bol uspesny
                    return(true);
                }
            }
            catch (Exception ex)
            {
                //zapis do trace, netusim kde recipients pojde
                ConsoleLogger.Info("Chyba pri zapise log suboru. {0}", ex);
#if DEBUG
                Debug.WriteLine(ex);
#endif
                //ukoncime s chybou
                return(false);
            }
            finally
            {
                //ukoncime zapisovac
                if (textWriter != null)
                {
                    textWriter.Close();
                    textWriter.Dispose();
                }
            }
        }
 /// <summary>
 /// Spracuje logovacie spravy. Ak sprava vyhovuje nastaveniam odosle ju vyssej vrstve
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// Argument 'message' je null alebo empty
 /// </exception>
 /// <param name="type">Typ spravy</param>
 /// <param name="message">Text spravy</param>
 /// <param name="msgArgs">Dalsie argumenty do String.Format k sprave</param>
 protected void InternalTrace(TraceTypes type, String message, params Object[] msgArgs)
 {
     //preposleme dalej
     this.InternalTrace(DateTime.Now, type, message, msgArgs);
 }
        public void ScopeTrace(Func <string> message, IDictionary <string, string> scopeProperties = null, bool triggerEvent = false, TraceTypes traceType = TraceTypes.Info)
        {
            telemetryScopedProperties.SetScopeProperties(scopeProperties);

            var save = RouteBinding?.Logging != null && traceType switch
            {
                TraceTypes.Info => RouteBinding?.Logging.ScopedLogger?.LogInfoTrace == true || RouteBinding?.Logging.ScopedStreamLoggers?.Where(l => l.LogInfoTrace).Any() == true,
                TraceTypes.Claim => RouteBinding?.Logging.ScopedLogger?.LogClaimTrace == true || RouteBinding?.Logging.ScopedStreamLoggers?.Where(l => l.LogClaimTrace).Any() == true,
                TraceTypes.Message => RouteBinding?.Logging.ScopedLogger?.LogMessageTrace == true || RouteBinding?.Logging.ScopedStreamLoggers?.Where(l => l.LogMessageTrace).Any() == true,
                _ => throw new NotSupportedException($"Trace type '{traceType}' not supported.")
            };

            var messageString = save || traceType == TraceTypes.Info && triggerEvent?message() : null;

            if (messageString != null)
            {
                if (traceType == TraceTypes.Info && triggerEvent)
                {
                    Event(messageString);
                }
                if (save)
                {
                    traceMessages.Add(new TraceMessage {
                        TraceType = traceType, Message = messageString
                    });
                }
            }
        }
 /// <summary>
 /// Zaloguje pozadovanu spravu do suboru
 /// </summary>
 /// <param name="type">Typ logovania</param>
 /// <param name="message">Sprava ktoru chceme zalogovat</param>
 /// <param name="args">Argumenty pre String.Format(message, args)</param>
 public static void OnTrace(TraceTypes type, String message, params Object[] args)
 {
     WebUtility.Trace(type, message, args);
 }