Possible levels for logging, as used in ILogProvider. LogLevel is implemented using the Descriptor pattern, which allows applications to extend and add their own log levels.
Inheritance: Descriptor
Exemplo n.º 1
0
        private static bool IsAllowed(LogLevel level)
        {
            var levelConfigured = StateManager.Settings["EventLogLevel"] as string;

            var config = Descriptor.Get<LogLevel>(levelConfigured) ?? LogLevel.Unspecified;

            return level.Order >= config.Order;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Logs the specified message with the specified <see cref="LogLevel"/> and user information.
        /// </summary>
        /// <param name="level">The <see cref="LogLevel"/> to log.</param>
        /// <param name="user">The user information to log.</param>
        public static void Log(LogLevel level, string message, IUser user = null)
        {
            var currentUser = GetCurrentUser();

            foreach (var logger in Loggers)
            {
                logger.Log(level, message, user ?? currentUser);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Logs the specified message with the specified loglevel and user information.
        /// </summary>
        /// <param name="message">The message to log.</param>
        /// <param name="level">The loglevel to log.</param>
        /// <param name="user">The user information to log.</param>
        public void Log(LogLevel level, string message, IUser user)
        {
            message = string.Format("{0} - ({1}).", message, Assembly.GetCallingAssembly().FullName);

            if (IsAllowed(level))
            {
                if (level == LogLevel.Informational) appLog.WriteEntry(message, EventLogEntryType.Information);
                else if (level == LogLevel.Warning) appLog.WriteEntry(message, EventLogEntryType.Warning);
                else if (level == LogLevel.Error) appLog.WriteEntry(message, EventLogEntryType.Error);
                else appLog.WriteEntry(message, EventLogEntryType.Information);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Logs the specified message with the specified <see cref="LogLevel"/> and user information.
 /// </summary>
 /// <param name="level">The <see cref="LogLevel"/> to log.</param>
 /// <param name="message">The message to log.</param>
 /// <param name="user">The user information to log.</param>
 public void Log(LogLevel level, string message, IUser user = null)
 {
     Debug.WriteLine(level + ": " + message);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Log the error message as per the specified log level.
        /// </summary>
        /// <param name="message">The error messages which will logged.</param>
        /// <param name="level">The Adf.Core.LogLevel that defines the comparison with configuration loglevel.</param>
        /// <param name="user">The Adf.Core.IDomainObject object - not in use.</param>
        public void Log(LogLevel level, string message, IUser user)
        {
            if (message == null) throw new ArgumentNullException("message");

            if (IsAllowed(level))
            {
                Log(message, user);
            }
        }