コード例 #1
0
ファイル: LogBase.cs プロジェクト: Aurora-and-Equinox/docky
		static void GLibLogFunc (string domain, LogLevelFlags level, string message)
		{
			LogLevel docky_log_level;
			
			switch (level) {
			case LogLevelFlags.Critical:
				docky_log_level = LogLevel.Fatal;
				break;
			case LogLevelFlags.Error:
				docky_log_level = LogLevel.Error;
				break;
			case LogLevelFlags.Warning:
				docky_log_level = LogLevel.Warn;
				break;
			case LogLevelFlags.Info:
			case LogLevelFlags.Message:
				docky_log_level = LogLevel.Info;
				break;
			case LogLevelFlags.Debug:
				docky_log_level = LogLevel.Debug;
				break;
			default:
				docky_log_level = LogLevel.Warn;
				break;
			}
			Write (docky_log_level, "[{0}] {1}", domain, message);
		}
コード例 #2
0
ファイル: Log.cs プロジェクト: sciyoshi/netgir
 public static void DefaultHandler(string logDomain, LogLevelFlags logLevel, string message)
 {
     IntPtr ndom = Marshaller.StringToPtrGStrdup (logDomain);
     IntPtr nmess = Marshaller.StringToPtrGStrdup (message);
     g_log_default_handler (ndom, logLevel, nmess, IntPtr.Zero);
     Marshaller.Free (ndom);
     Marshaller.Free (nmess);
 }
コード例 #3
0
ファイル: Log.cs プロジェクト: ystk/debian-gtk-sharp2
		public void WriteLog (string logDomain, LogLevelFlags flags, string format, params object [] args)
		{
			IntPtr ndom = Marshaller.StringToPtrGStrdup (logDomain);
			IntPtr nmessage = Marshaller.StringToPtrGStrdup (String.Format (format, args));
			g_logv (ndom, flags, nmessage);
			Marshaller.Free (ndom);
			Marshaller.Free (nmessage);
		}
コード例 #4
0
ファイル: Log.cs プロジェクト: ystk/debian-gtk-sharp2
		public static uint SetLogHandler (string logDomain, LogLevelFlags flags, LogFunc logFunc)
		{
			IntPtr ndom = Marshaller.StringToPtrGStrdup (logDomain);
			uint result = g_log_set_handler (ndom, flags, logFunc, IntPtr.Zero);
			Marshaller.Free (ndom);
			EnsureHash ();
			handlers [result] = logFunc;

			return result;
		}
コード例 #5
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
		static void NativeCallback (IntPtr log_domain_native, LogLevelFlags flags, IntPtr message_native, IntPtr user_data)
		{
			if (user_data == IntPtr.Zero)
				return;
			string log_domain = Marshaller.Utf8PtrToString (log_domain_native);
			string message = Marshaller.Utf8PtrToString (message_native);
			GCHandle gch = (GCHandle) user_data;
			LogFunc func = gch.Target as LogFunc;
			if (func != null)
				func (log_domain, flags, message);
		}
コード例 #6
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
		/*
		 * Some common logging methods.
		 *
		 * Sample usage:
		 *
		 *	// Print the messages for the NULL domain
		 *	LogFunc logFunc = new LogFunc (Log.PrintLogFunction);
		 *	Log.SetLogHandler (null, LogLevelFlags.All, logFunc);
		 *
		 *	// Print messages and stack trace for Gtk critical messages
		 *	logFunc = new LogFunc (Log.PrintTraceLogFunction);
		 *	Log.SetLogHandler ("Gtk", LogLevelFlags.Critical, logFunc);
		 *
		 */

		public static void PrintLogFunction (string domain, LogLevelFlags level, string message)
		{
			Console.WriteLine ("Domain: '{0}' Level: {1}", domain, level);
			Console.WriteLine ("Message: {0}", message);
		}
コード例 #7
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
		public static LogLevelFlags SetAlwaysFatal (string logDomain, LogLevelFlags fatalMask)
		{
			IntPtr ndom = Marshaller.StringToPtrGStrdup (logDomain);
			LogLevelFlags result = g_log_set_fatal_mask (ndom, fatalMask);
			Marshaller.Free (ndom);
			return result;
		}
コード例 #8
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
		public static LogLevelFlags SetAlwaysFatal (LogLevelFlags fatalMask)
		{
			return g_log_set_always_fatal (fatalMask);
		}
コード例 #9
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
		static extern void g_log_default_handler (IntPtr log_domain, LogLevelFlags log_level, IntPtr message, IntPtr unused_data);
コード例 #10
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
		static extern uint g_log_set_handler (IntPtr log_domain, LogLevelFlags flags, LogFuncNative log_func, IntPtr user_data);
コード例 #11
0
 public static LogLevelFlags SetAlwaysFatal(LogLevelFlags fatalMask)
 {
     return(g_log_set_always_fatal(fatalMask));
 }
コード例 #12
0
ファイル: GLibLogging.cs プロジェクト: Kalnor/monodevelop
		static void LoggerMethod (string logDomain, LogLevelFlags logLevel, string message)
		{
			if (RemainingBytes < 0)
				return;

			System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace (2, true);
			string msg = string.Format ("{0}-{1}: {2}\nStack trace: \n{3}", 
			    logDomain, logLevel, message, trace.ToString ());

			switch (logLevel) {
			case LogLevelFlags.Debug:
				LoggingService.LogDebug (msg);
				break;
			case LogLevelFlags.Info:
				LoggingService.LogInfo (msg);
				break;
			case LogLevelFlags.Warning:
				LoggingService.LogWarning (msg);
				break;
			case LogLevelFlags.Error:
			case LogLevelFlags.Critical:
			default:
				LoggingService.LogError (msg);
				break;
			}
			
			RemainingBytes -= msg.Length;
			if (RemainingBytes < 0)
				LoggingService.LogError ("Disabling glib logging for the rest of the session");
		}
コード例 #13
0
 static extern void g_log(IntPtr logDomain, LogLevelFlags logLevel, IntPtr format);
コード例 #14
0
        /// <summary>
        /// Sets the message levels which are always fatal, in any log domain.
        /// When a message with any of these levels is logged the program terminates.
        /// You can only set the levels defined by GLib to be fatal.
        /// <see cref="LogLevelFlags.Error"/> is always fatal.
        /// </summary>
        /// <remarks>
        /// You can also make some message levels fatal at runtime by setting
        /// the <c>G_DEBUG</c> environment variable (see
        /// [Running GLib Applications](glib-running.html)).
        ///
        /// Libraries should not call this function, as it affects all messages logged
        /// by a process, including those from other libraries.
        ///
        /// Structured log messages (using g_log_structured() and
        /// g_log_structured_array()) are fatal only if the default log writer is used;
        /// otherwise it is up to the writer function to determine which log messages
        /// are fatal. See [Using Structured Logging][using-structured-logging].
        /// </remarks>
        /// <param name="fatalMask">
        /// the mask containing bits set for each level
        /// of error which is to be fatal
        /// </param>
        /// <returns>
        /// the old fatal mask
        /// </returns>
        public static LogLevelFlags SetAlwaysFatal(LogLevelFlags fatalMask)
        {
            var ret = g_log_set_always_fatal(fatalMask);

            return(ret);
        }
コード例 #15
0
 /* <type name="LogLevelFlags" type="GLogLevelFlags" managed-name="LogLevelFlags" /> */
 /* transfer-ownership:none */
 static extern LogLevelFlags g_log_set_always_fatal(
     /* <type name="LogLevelFlags" type="GLogLevelFlags" managed-name="LogLevelFlags" /> */
     /* transfer-ownership:none */
     LogLevelFlags fatalMask);
コード例 #16
0
 public static bool HasMessage(LogLevelFlags severity, string msg)
 {
     return m_DebugEntries.Find(x => (x.severity == severity) && (x.msg == msg)) != null;
 }
コード例 #17
0
        public static LogWriterOutput Invoke(LogLevelFlags logLevel, LogField[] fields, UIntPtr nfields, IntPtr userData)
        {
            var logWriterFunc = (LogWriterFunc)GCHandle.FromIntPtr(userData).Target;

            return(logWriterFunc(logLevel, fields));
        }
コード例 #18
0
ファイル: GLibLogging.cs プロジェクト: Viviane788/monodevelop
 extern static LogLevelFlags g_log_set_fatal_mask(IntPtr log_domain, LogLevelFlags fatal_mask);
コード例 #19
0
 extern static LogLevelFlags g_log_set_always_fatal(LogLevelFlags fatal_mask);
コード例 #20
0
ファイル: GLibLogging.cs プロジェクト: Viviane788/monodevelop
        static void LoggerMethod(IntPtr logDomainPtr, LogLevelFlags logLevel, IntPtr messagePtr)
        {
            if (RemainingBytes < 0)
            {
                return;
            }

            string logDomain = GLib.Marshaller.Utf8PtrToString(logDomainPtr);
            string message;

            try {
                // Marshal message manually, because the text can contain invalid UTF-8.
                // Specifically, with zh_CN, pango fails to render some characters and
                // pango's error message contains the broken UTF-8, thus on marshalling
                // we need to catch the exception, otherwise we end up in a recursive
                // glib exception handling.
                message = GLib.Marshaller.Utf8PtrToString(messagePtr);
            } catch (Exception e) {
                message = "Failed to convert message";
                LoggingService.LogError(message, e);
            }

            var stackTraceString = new System.Diagnostics.StackTrace(2, true).ToString();

            string msg = string.Format("{0}-{1}: {2}", logDomain, logLevel, message);

            switch (logLevel)
            {
            case LogLevelFlags.Debug:
                LoggingService.LogDebug(msg);
                break;

            case LogLevelFlags.Info:
                LoggingService.LogInfo(msg);
                break;

            case LogLevelFlags.Warning:
                LoggingService.LogWarning(msg);
                break;

            case LogLevelFlags.Error:
            case LogLevelFlags.Critical:
            default:
                var exception = new CriticalGtkException(message, stackTraceString);
                if (logLevel.HasFlag(LogLevelFlags.FlagFatal))
                {
                    LoggingService.LogFatalError("Fatal GLib error", exception);
                }
                else
                {
                    LoggingService.LogInternalError("Critical GLib error", exception);
                }
                break;
            }

            RemainingBytes -= msg.Length;
            if (RemainingBytes < 0)
            {
                LoggingService.LogError("Disabling glib logging for the rest of the session");
            }
        }
コード例 #21
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
		static extern void g_logv (IntPtr log_domain, LogLevelFlags flags, IntPtr message);
コード例 #22
0
ファイル: GLibLogging.cs プロジェクト: Viviane788/monodevelop
 static extern void g_logv(IntPtr log_domain, LogLevelFlags flags, IntPtr message);
コード例 #23
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
		public static uint SetLogHandler (string logDomain, LogLevelFlags flags, LogFunc logFunc)
		{
			if (native_handler == null)
				native_handler = new LogFuncNative (NativeCallback);

			IntPtr ndom = Marshaller.StringToPtrGStrdup (logDomain);
			GCHandle gch = GCHandle.Alloc (logFunc);
			uint result = g_log_set_handler (ndom, flags, native_handler, (IntPtr) gch);
			Marshaller.Free (ndom);
			EnsureHash ();
			handlers [result] = gch;
			return result;
		}
コード例 #24
0
ファイル: GLibLogging.cs プロジェクト: Viviane788/monodevelop
 static extern uint g_log_set_handler(IntPtr log_domain, LogLevelFlags flags, LogFunc2 log_func, LogFunc user_data);
コード例 #25
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
		extern static LogLevelFlags g_log_set_always_fatal (LogLevelFlags fatal_mask);
コード例 #26
0
        /*
         * Some common logging methods.
         *
         * Sample usage:
         *
         *	// Print the messages for the NULL domain
         *	LogFunc logFunc = new LogFunc (Log.PrintLogFunction);
         *	Log.SetLogHandler (null, LogLevelFlags.All, logFunc);
         *
         *	// Print messages and stack trace for Gtk critical messages
         *	logFunc = new LogFunc (Log.PrintTraceLogFunction);
         *	Log.SetLogHandler ("Gtk", LogLevelFlags.Critical, logFunc);
         *
         */

        public static void PrintLogFunction(string domain, LogLevelFlags level, string message)
        {
            Console.WriteLine("Domain: '{0}' Level: {1}", domain, level);
            Console.WriteLine("Message: {0}", message);
        }
コード例 #27
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
		extern static LogLevelFlags g_log_set_fatal_mask (IntPtr log_domain, LogLevelFlags fatal_mask);
コード例 #28
0
 public static void PrintTraceLogFunction(string domain, LogLevelFlags level, string message)
 {
     PrintLogFunction(domain, level, message);
     Console.WriteLine("Trace follows:\n{0}", new System.Diagnostics.StackTrace());
 }
コード例 #29
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
			void Invoke (string log_domain, LogLevelFlags flags, string message)
			{
				IntPtr ndom = Marshaller.StringToPtrGStrdup (log_domain);
				IntPtr nmess = Marshaller.StringToPtrGStrdup (message);
				native (ndom, flags, nmess, IntPtr.Zero);
				Marshaller.Free (ndom);
				Marshaller.Free (nmess);
			}
コード例 #30
0
ファイル: UnityLogger.cs プロジェクト: jch1999/PlantList-Test
 private void SetFlag(bool active, LogLevelFlags flag)
 {
     _levels = active
         ? _levels | flag
         : _levels & (~flag);
 }
コード例 #31
0
ファイル: Log.cs プロジェクト: liberostelios/gtk-sharp
		public static void PrintTraceLogFunction (string domain, LogLevelFlags level, string message)
		{
			PrintLogFunction (domain, level, message);
			Console.WriteLine ("Trace follows:\n{0}", new System.Diagnostics.StackTrace ());
		}
コード例 #32
0
 static extern void g_log_default_handler(IntPtr log_domain, LogLevelFlags log_level, IntPtr message, IntPtr unused_data);
コード例 #33
0
ファイル: UnityLogger.cs プロジェクト: jch1999/PlantList-Test
 public UnityLogger()
 {
     _levels = LogLevelFlags.Critical | LogLevelFlags.Error | LogLevelFlags.Information;
 }
コード例 #34
0
ファイル: UnityLogger.cs プロジェクト: jch1999/PlantList-Test
 private static LogType ToLogType(LogLevelFlags logLevelFlags)
 {
     return(logLevelFlags == LogLevelFlags.Error || logLevelFlags == LogLevelFlags.Critical
         ? LogType.Error
         : LogType.Log);
 }