Exemple #1
0
        public static void Write(char identificator, string subject, string comment = null, Exception ex = null)
        {
            if (!IntentoTranslationProviderOptionsForm.IsTrace())
            {
                return;
            }

            try
            {
                DateTime      now     = DateTime.UtcNow;
                List <string> content = new List <string>();
                content.Add(string.Format("{0} {1}", now.ToString("yyyy-MM-dd HH:mm:ss.fffff"), subject));
                if (comment != null)
                {
                    content.Add(comment);
                }
                if (ex != null)
                {
                    content.AddRange(LoggingEx(identificator, ex));
                }

                WriteRemoteLog(identificator, string.Join("\n", content.ToArray()));
            }
            catch { }
        }
Exemple #2
0
        public static bool IsLogging()
        {
            string env = Environment.GetEnvironmentVariable("intento_plugin_logging");

            if (env != null)
            {
                env = env.ToLower();
                if (env == "1" || env == "true")
                {
                    return(true);
                }
            }
            return(IntentoTranslationProviderOptionsForm.IsTrace());
        }
Exemple #3
0
        //[Obsolete("Logging is deprecated, please use Write instead.")]
        public static void Logging(string subject, string comment = null, Exception ex = null)
        {
            if (!IntentoTranslationProviderOptionsForm.IsTrace())
            {
                return;
            }

            try
            {
                DateTime      now     = DateTime.UtcNow;
                List <string> content = new List <string>();
                content.Add("------------------------");
                content.Add(string.Format("{0} {1}", now.ToString("yyyy-MM-dd HH:mm:ss.fffff"), subject));
                if (comment != null)
                {
                    content.Add(comment);
                }
                if (ex != null)
                {
                    content.AddRange(LoggingEx('U', ex));
                }

                string flag = Environment.GetEnvironmentVariable("file_logging");
                if (string.IsNullOrEmpty(flag))
                {
                    Write('U', string.Join("\n", content.ToArray()));
                }
                else
                {
                    string path = Environment.GetEnvironmentVariable("temp");
                    if (string.IsNullOrEmpty(path))
                    {
                        path = Environment.GetEnvironmentVariable("tmp");
                    }
                    if (string.IsNullOrEmpty(path))
                    {
                        return;
                    }
                    string filename = string.Format("{0}\\Intento_Logs_{1}", path, now.ToString("yyyy-MM-dd-HH"));
                    File.AppendAllLines(filename, content);
                }
            }
            catch { }
        }