public void UsageLog(LogType logType, ServiceLogLevel logLevel, string connectorName, string connectorVersion,
                      string docCode, string operation, string serviceUrl, string source, int lineCount, EventBlock eventBlock, string functionName, TimeType timeType, string callerAcctNum, string licenseKey, String message, Boolean writeToLocalFile, Boolean writeToLogEntries, string folderPath = "")
 {
     try
     {
         InitializeAppender(writeToLocalFile, writeToLogEntries, callerAcctNum, licenseKey, connectorName, folderPath);
         ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object state)
         {
             WriteLogs(callerAcctNum, logType, logLevel, connectorName, connectorVersion,
                       docCode, operation, serviceUrl, source, lineCount, eventBlock, functionName, timeType, licenseKey, message,
                       writeToLocalFile, writeToLogEntries, folderPath);
         }), null);
     }
     catch (Exception ex)
     {
         try
         {
             LogMessages("Error in Logging.");
             LogMessages(ex.Message.ToString());
             if (ex.InnerException != null)
             {
                 LogMessages(ex.InnerException.ToString());
             }
         }
         catch (Exception)
         {
         }
     }
 }
Exemplo n.º 2
0
 public void Write(ServiceLogLevel level, string msg)
 {
     foreach (var log in m_logs)
     {
         if (log.Level <= level)
         {
             log.Write(level, msg);
         }
     }
 }
Exemplo n.º 3
0
        public void Add(IServiceLog log)
        {
            m_logs.Add(log);
            var l = log.Level;

            if (l < Level)
            {
                Level = l;
            }
        }
Exemplo n.º 4
0
 public void Write(ServiceLogLevel level, string msg)
 {
     if (m_isOpen == 1)
     {
         try
         {
             m_writer.WriteLine($"{DateTime.Now.ToString("yyMMdd HH:mm:ss,ffff")} [{level}] {msg}");
         }
         catch
         {
         }
     }
 }
        private void WriteLogs(string callerAcctNum, LogType logType, ServiceLogLevel logLevel, string connectorName,
                               string connectorVersion, string docCode,
                               string operation, string serviceUrl, string source, int lineCount, EventBlock eventBlock,
                               string functionName, TimeType timeType, string licenseKey, string message, Boolean writeToLocalFile, Boolean writeToLogEntries, string folderPath)
        {
            try
            {
                string msg = string.Empty;
                if (message == string.Empty)
                {
                    msg = string.Format("LINECOUNT - {0} :: {1} : {2} - {3}",
                                        lineCount,
                                        (eventBlock == EventBlock.InternalFunction) ? functionName : eventBlock.ToString(),
                                        timeType.ToString(),
                                        DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffzzz")
                                        );
                }
                else
                {
                    msg = message;
                }

                string logMessage = string.Empty;
                logMessage = "[";
                logMessage = logMessage + "{\"" + "CallerAcctNum" + "\"" + ":" + "\"" + callerAcctNum + "\"}";
                logMessage = logMessage + "{\"" + "LogType" + "\"" + ":" + "\"" + GetLogTypeAsString(logType) + "\"}";
                logMessage = logMessage + "{\"" + "LogLevel" + "\"" + ":" + "\"" + GetLogLevelAsString(logLevel) + "\"}";
                logMessage = logMessage + "{\"" + "ConnectorName" + "\"" + ":" + "\"" + connectorName + "\"}";
                logMessage = logMessage + "{\"" + "ConnectorVersion" + "\"" + ":" + "\"" + connectorVersion + "\"}";
                logMessage = logMessage + "{\"" + "Operation" + "\"" + ":" + "\"" + operation + "\"}";
                logMessage = logMessage + "{\"" + "ServiceURL" + "\"" + ":" + "\"" + serviceUrl + "\"}";
                logMessage = logMessage + "{\"" + "Source" + "\"" + ":" + "\"" + source + "\"}";
                logMessage = logMessage + "{\"" + "DocCode" + "\"" + ":" + "\"" + docCode + "\"}";
                logMessage = logMessage + "{\"" + "Message" + "\"" + ":" + "\"" + msg + "\"}";
                logMessage = logMessage + "]";

                LogToLogEntries(logMessage);
            }
            catch (Exception ex)
            {
                LogMessages("-----------------------------------------");
                LogMessages("Error while writing logs ");
                LogMessages(ex.Message);
                LogMessages(ex.StackTrace);
                if (ex.InnerException != null)
                {
                    LogMessages(ex.InnerException.ToString());
                }
            }
        }
        private void WriteLogs(string callerAcctNum, LogType logType, ServiceLogLevel logLevel, string connectorName, string connectorVersion, string operation, string serviceUrl, string functionName, string source, string message, string licenseKey, Boolean writeToLocalFile, Boolean writeToLogEntries, string folderPath = "")
        {
            try
            {
                string logMessage = string.Empty;
                logMessage = "[";
                logMessage = logMessage + "{\"" + "CallerAcctNum" + "\"" + ":" + "\"" + callerAcctNum + "\"}";
                logMessage = logMessage + "{\"" + "LogType" + "\"" + ":" + "\"" + GetLogTypeAsString(logType) + "\"}";
                logMessage = logMessage + "{\"" + "LogLevel" + "\"" + ":" + "\"" + GetLogLevelAsString(logLevel) + "\"}";
                logMessage = logMessage + "{\"" + "ConnectorName" + "\"" + ":" + "\"" + connectorName + "\"}";
                logMessage = logMessage + "{\"" + "ConnectorVersion" + "\"" + ":" + "\"" + connectorVersion + "\"}";
                logMessage = logMessage + "{\"" + "Operation" + "\"" + ":" + "\"" + operation + "\"}";
                logMessage = logMessage + "{\"" + "ServiceURL" + "\"" + ":" + "\"" + serviceUrl + "\"}";
                logMessage = logMessage + "{\"" + "Source" + "\"" + ":" + "\"" + source + "\"}";
                logMessage = logMessage + "{\"" + "FunctionName" + "\"" + ":" + "\"" + functionName + "\"}";
                logMessage = logMessage + "{\"" + "Message" + "\"" + ":" + "\"" + message + "\"}";
                logMessage = logMessage + "]";


                LogToLogEntries(logMessage);
            }
            catch (Exception ex)
            {
                try
                {
                    LogMessages("-----------------------------------------");
                    LogMessages("Error while writing logs ");
                    LogMessages(ex.Message);
                    LogMessages(ex.StackTrace);
                    if (ex.InnerException != null)
                    {
                        LogMessages(ex.InnerException.ToString());
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Exemplo n.º 7
0
        public void Write(ServiceLogLevel level, string evt)
        {
            switch (level)
            {
            case ServiceLogLevel.Info:
                EventLog.WriteEntry(Source, evt, EventLogEntryType.Information, 0x03);
                break;

            case ServiceLogLevel.Warning:
                EventLog.WriteEntry(Source, evt, EventLogEntryType.Warning, 0x01);
                break;

            case ServiceLogLevel.Error:
                EventLog.WriteEntry(Source, evt, EventLogEntryType.Error, 0x02);
                break;

            case ServiceLogLevel.Trace:
            case ServiceLogLevel.Debug:
            default:
                break;
            }
        }
        private string GetLogLevelAsString(ServiceLogLevel logLevel)
        {
            String returnValue;

            switch (logLevel)
            {
            case ServiceLogLevel.Error:
                returnValue = "Error";
                break;

            case ServiceLogLevel.Exception:
                returnValue = "Exception";
                break;

            case ServiceLogLevel.Informational:
                returnValue = "Informational";
                break;

            default:
                returnValue = "";
                break;
            }
            return(returnValue);
        }
Exemplo n.º 9
0
 public void Write(ServiceLogLevel level, string msg)
 {
     Debug.Print($"{DateTime.Now.ToString("yyMMdd HH:mm:ss,ffff")} [{level}] {msg}");
 }
Exemplo n.º 10
0
 // log
 /// <summary>
 /// Writes the specified level.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="ex">The ex.</param>
 /// <param name="s">The s.</param>
 public void Write(ServiceLogLevel level, Exception ex, string s)
 {
     if (Log == null)
         throw new NullReferenceException("Log");
     if (ex != null)
         s = GetExceptionMessage(ex, s);
     switch (level)
     {
         case ServiceLogLevel.Fatal: Log.Log(s, EventID, EventSeverity.ErrorCritical, Name); return;
         case ServiceLogLevel.Error: Log.Log(s, EventID, EventSeverity.Error, Name); return;
         case ServiceLogLevel.Warning: Log.Log(s, EventID, EventSeverity.Warning, Name); return;
         case ServiceLogLevel.Information: Log.Log(s, EventID, EventSeverity.Information, Name); return;
         case ServiceLogLevel.Debug: Log.Log(s, EventID, EventSeverity.Verbose, Name); return;
         default: return;
     }
 }
Exemplo n.º 11
0
 // log
 /// <summary>
 /// Writes the specified level.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="ex">The ex.</param>
 /// <param name="s">The s.</param>
 public void Write(ServiceLogLevel level, Exception ex, string s)
 {
     if (Log == null)
         throw new NullReferenceException("Log");
     switch (level)
     {
         case ServiceLogLevel.Fatal: Log.Fatal(s, ex); return;
         case ServiceLogLevel.Error: Log.Error(s, ex); return;
         case ServiceLogLevel.Warning: Log.Warn(s, ex); return;
         case ServiceLogLevel.Information: Log.Info(s, ex); return;
         case ServiceLogLevel.Debug: Log.Debug(s, ex); return;
         default: return;
     }
 }
Exemplo n.º 12
0
 // log
 /// <summary>
 /// Writes the specified level.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="ex">The ex.</param>
 /// <param name="s">The s.</param>
 public void Write(ServiceLogLevel level, Exception ex, string s)
 {
     if (Log == null)
         throw new NullReferenceException("Log");
     var message = string.Format(CultureInfo.CurrentCulture, "[{0}] '{1}' message: {2}", level.ToString(), Name, s);
     if (ex == null)
         switch (level)
         {
             case ServiceLogLevel.Fatal:
                 Log.Fatal(message);
                 return;
             case ServiceLogLevel.Error:
                 Log.Error(message);
                 return;
             case ServiceLogLevel.Warning:
                 Log.Warn(message);
                 return;
             case ServiceLogLevel.Information:
                 Log.Info(message);
                 return;
             case ServiceLogLevel.Debug:
                 Log.Debug(message);
                 return;
             default:
                 return;
         }
     else
         switch (level)
         {
             case ServiceLogLevel.Fatal:
                 Log.Fatal(message, ex);
                 return;
             case ServiceLogLevel.Error:
                 Log.Error(message, ex);
                 return;
             case ServiceLogLevel.Warning:
                 Log.Warn(message, ex);
                 return;
             case ServiceLogLevel.Information:
                 Log.Info(message, ex);
                 return;
             case ServiceLogLevel.Debug:
                 Log.Debug(message, ex);
                 return;
             default:
                 return;
         }
 }