Exemple #1
0
        /// <summary>
        /// Send a single message to syslog, handling Openlog() and Closelog() properly.
        /// </summary>
        /// <param name="priority"></param>
        /// <param name="message"></param>
        public void Log(SyslogPriority priority, string message)
        {
            IntPtr handle = Openlog();

            try
            {
                Syslog(priority, message);
            }
            finally
            {
                Closelog(ref handle);
            }
        }
Exemple #2
0
        /// <summary>
        /// For efficiency, if you have many messages to log with the same priority, LogMany() will log them all
        /// with only a single Openlog() / Closelog() call pair.
        /// </summary>
        /// <param name="priority"></param>
        /// <param name="messages"></param>
        public void LogMany(SyslogPriority priority, IEnumerable <string> messages)
        {
            IntPtr handle = Openlog();

            try
            {
                foreach (string message in messages)
                {
                    Syslog(priority, message);
                }
            }
            finally
            {
                Closelog(ref handle);
            }
        }
Exemple #3
0
 /// <summary>
 /// Sends a message to the syslog previously opened by Openlog(). If called without calling Openlog() first,
 /// the app name in the syslog will be "mono", which is usually not what you want. If you want String.Format()
 /// style parameters, use the Alert/Critical/Error/etc convenience functions.
 /// <para />
 /// Note that the libc_syslog() call expects a UTF-8 encoded string with no BOM, but Syslog() will take care
 /// of encoding your string for you.
 /// </summary>
 /// <param name="priority">Priority of the log message (a SyslogPriority enum value)</param>
 /// <param name="message">The C# string to be logged</param>
 private void Syslog(SyslogPriority priority, string message)
 {
     Syscall.syslog((Mono.Unix.Native.SyslogFacility)Facility, (Mono.Unix.Native.SyslogLevel)priority, message);
 }
Exemple #4
0
		/// <summary>
		/// Sends a message to the syslog previously opened by Openlog(). If called without calling Openlog() first,
		/// the app name in the syslog will be "mono", which is usually not what you want. If you want String.Format()
		/// style parameters, use the Alert/Critical/Error/etc convenience functions.
		/// <para />
		/// Note that the libc_syslog() call expects a UTF-8 encoded string with no BOM, but Syslog() will take care
		/// of encoding your string for you.
		/// </summary>
		/// <param name="priority">Priority of the log message (a SyslogPriority enum value)</param>
		/// <param name="message">The C# string to be logged</param>
		private void Syslog(SyslogPriority priority, string message)
		{
			Syscall.syslog((Mono.Unix.Native.SyslogFacility)Facility, (Mono.Unix.Native.SyslogLevel)priority, message);
		}
Exemple #5
0
		/// <summary>
		/// For efficiency, if you have many messages to log with the same priority, LogMany() will log them all
		/// with only a single Openlog() / Closelog() call pair.
		/// </summary>
		/// <param name="priority"></param>
		/// <param name="messages"></param>
		public void LogMany(SyslogPriority priority, IEnumerable<string> messages)
		{
			IntPtr handle = Openlog();
			try
			{ 
				foreach (string message in messages)
					Syslog(priority, message);
			}
			finally
			{
				Closelog(ref handle);
			}
		}
Exemple #6
0
		/// <summary>
		/// Send a single message to syslog, handling Openlog() and Closelog() properly.
		/// </summary>
		/// <param name="priority"></param>
		/// <param name="message"></param>
		public void Log(SyslogPriority priority, string message)
		{
			IntPtr handle = Openlog();
			try
			{
				Syslog(priority, message);
			}
			finally
			{
				Closelog(ref handle);
			}
		}