Exemple #1
0
        /// <summary>
        /// Submits a log entry to the NeonSwitch logging subsystem.
        /// </summary>
        /// <param name="level">The log level.</param>
        /// <param name="message">The log message.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="message" /> is <c>null</c>.</exception>
        public static void Log(SwitchLogLevel level, string message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            Execute("log", "{0} {1}", SwitchHelper.GetSwitchLogLevelString(level), message);
        }
Exemple #2
0
        /// <summary>
        /// Returns the low-level FreeSWITCH string corresponding to a <see cref="SwitchLogLevel" />.
        /// </summary>
        /// <param name="logLevel">The log level.</param>
        /// <returns>The corresponding string or <b>NONE</b> if the code is unknown.</returns>
        public static string GetSwitchLogLevelString(SwitchLogLevel logLevel)
        {
            string logLevelString;

            if (!switchLogLevelToString.TryGetValue(logLevel, out logLevelString))
            {
                SysLog.LogWarning("Unexpected channel log level [{0}].", logLevel);
                logLevelString = switchLogLevelToString[SwitchLogLevel.None];
            }

            return(logLevelString);
        }
Exemple #3
0
        /// <summary>
        /// Submits a formatted log entry to the NeonSwitch logging subsystem.
        /// </summary>
        /// <param name="level">The log level.</param>
        /// <param name="format">The format string.</param>
        /// <param name="args">The arguments.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="format" /> or <paramref name="args"/> is <c>null</c>.</exception>
        public static void Log(SwitchLogLevel level, string format, params object[] args)
        {
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }

            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            Execute("log", "{0} {1}", SwitchHelper.GetSwitchLogLevelString(level), string.Format(format, args));
        }
Exemple #4
0
 /// <summary>
 /// Constructs an action to change the log level of the specified call.
 /// </summary>
 /// <param name="callID">The target call ID.</param>
 /// <param name="level">The new log level.</param>
 public LogLevelAction(Guid callID, SwitchLogLevel level)
 {
     this.CallID = callID;
     this.level  = level;
 }
Exemple #5
0
 /// <summary>
 /// Constructs an action to change the log level of the current
 /// call in an executing dialplan.
 /// </summary>
 /// <param name="level">The new log level.</param>
 public LogLevelAction(SwitchLogLevel level)
 {
     this.level = level;
 }
Exemple #6
0
 /// <summary>
 /// Constructs an action that logs text at the specified level.
 /// </summary>
 /// <param name="level">The new log level.</param>
 /// <param name="text">The text to be logged.</param>
 public LogAction(SwitchLogLevel level, string text)
     : base("log", string.Format("{0} {1}", SwitchHelper.GetSwitchLogLevelString(level), text))
 {
 }