Пример #1
0
        internal static void Commit(
            LogLevel level,
            LogFlags flags,
            string tag,
            string message,
            Exception exception = null,
            [CallerMemberName] string callerMemberName = null,
            [CallerFilePath] string callerFilePath     = null,
            [CallerLineNumber] int callerLineNumber    = 0)
        {
            var time = DateTime.UtcNow;

            provider.Commit(new LogEntry(
                                null,
                                time,
                                time - startTime,
                                level,
                                flags,
                                tag,
                                message,
                                exception,
                                callerMemberName,
                                callerFilePath,
                                callerLineNumber));
        }
Пример #2
0
 internal LogEntry(
     string ownerId,
     DateTime time,
     TimeSpan relativeTime,
     LogLevel level,
     LogFlags flags,
     string tag,
     string message,
     Exception exception,
     string callerMemberName,
     string callerFilePath,
     int callerLineNumber)
 {
     OwnerId          = ownerId;
     Time             = time;
     RelativeTime     = relativeTime;
     Level            = level;
     Flags            = flags;
     Tag              = tag;
     Message          = message;
     this.exception   = exception;
     CallerMemberName = callerMemberName;
     CallerFilePath   = callerFilePath;
     CallerLineNumber = callerLineNumber;
 }
Пример #3
0
        private void BubbleException(LogFlags flags, Exception ex)
        {
            switch (Type)
            {
            case LogTypes.Trace:
                LoggerBundle.Debug(flags, ex);
                break;

            case LogTypes.Debug:
                LoggerBundle.Inform(flags, ex);
                break;

            case LogTypes.Info:
                LoggerBundle.Warn(flags, ex);
                break;

            case LogTypes.Warning:
                LoggerBundle.Error(flags, ex);
                break;

            case LogTypes.Error:
                LoggerBundle.Fatal(flags, ex);
                break;

            case LogTypes.Fatal:
                throw ex;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #4
0
        private void TestSimpleMessage(Socket serverSocket, bool dontAppendSyslogIdentifier)
        {
            using (var message = Journal.GetMessage())
            {
                // Message is enabled
                Assert.True(message.IsEnabled);

                message.Append("FIELD", "Value");

                // This shouldn't throw.
                LogFlags flags = LogFlags.Information;
                if (dontAppendSyslogIdentifier)
                {
                    flags |= LogFlags.DontAppendSyslogIdentifier;
                }
                LogResult result = Journal.Log(flags, message);
                Assert.Equal(LogResult.Success, result);

                var fields = ReadFields(serverSocket);
                if (dontAppendSyslogIdentifier)
                {
                    Assert.Equal(2, fields.Count);
                }
                else
                {
                    Assert.Equal(3, fields.Count);
                }
                Assert.Equal("Value", fields["FIELD"]);
                Assert.Equal("6", fields["PRIORITY"]);
                if (!dontAppendSyslogIdentifier)
                {
                    Assert.Equal(Journal.SyslogIdentifier, fields["SYSLOG_IDENTIFIER"]);
                }
            }
        }
Пример #5
0
 public virtual void OnLogAction(LogPriority priority, LogFlags type, string message)
 {
     Output?.Invoke(this, new LoggerEventArgs()
     {
         Priority = priority, Flags = type, Message = message, Exception = null
     });
 }
Пример #6
0
 internal ConsoleColor GetColorFromType(LogFlags flags)
 {
     if (flags.HasFlag(LogFlags.APP))
     {
         return(ConsoleColor.DarkGray);
     }
     if (flags.HasFlag(LogFlags.DEBUG))
     {
         return(ConsoleColor.DarkCyan);
     }
     if (flags.HasFlag(LogFlags.ERROR))
     {
         return(ConsoleColor.Red);
     }
     if (flags.HasFlag(LogFlags.NOTICE))
     {
         return(ConsoleColor.Yellow);
     }
     if (flags.HasFlag(LogFlags.IMPORANT))
     {
         return(ConsoleColor.Magenta);
     }
     if (flags.HasFlag(LogFlags.INFO))
     {
         return(m_DefaultColor);
     }
     return(m_DefaultColor);
 }
Пример #7
0
        /// <summary>
        /// Set ffmpeg log
        /// </summary>
        /// <param name="logLevel">log level</param>
        /// <param name="logFlags">log flags, support &amp; operator </param>
        /// <param name="logWrite">set <see langword="null"/> to use default log output</param>
        public static void SetupLogging(LogLevel logLevel = LogLevel.Verbose, LogFlags logFlags = LogFlags.PrintLevel, Action <string> logWrite = null)
        {
            unsafe
            {
                ffmpeg.av_log_set_level((int)logLevel);
                ffmpeg.av_log_set_flags((int)logFlags);

                if (logWrite == null)
                {
                    logCallback = ffmpeg.av_log_default_callback;
                }
                else
                {
                    logCallback = (p0, level, format, vl) =>
                    {
                        if (level > ffmpeg.av_log_get_level())
                        {
                            return;
                        }
                        var lineSize    = 1024;
                        var printPrefix = 1;
                        var lineBuffer  = stackalloc byte[lineSize];
                        ffmpeg.av_log_format_line(p0, level, format, vl, lineBuffer, lineSize, &printPrefix);
                        logWrite.Invoke(((IntPtr)lineBuffer).PtrToStringUTF8());
                    };
                }
                ffmpeg.av_log_set_callback(logCallback);
            }
        }
Пример #8
0
        public static void Error(LogFlags flags, params object[] args)
        {
#if ULINK
            uLink.Log.Error(uLink.NetworkLogFlags.Socket, args);
#elif ULINK_TOOL
            uLink.ConsoleMain.Log(String.Concat(args));
#elif ULOBBY
            uLobby.Log.Error(uLobby.LogFlags.Network, args);
#endif
        }
Пример #9
0
 public BeamerLogCfg(
     string filePath, bool enabled = true, LogFlags trace = (LogFlags)((1 << 17) - 1),
     string ext = "brays", int rotSizeKb = 5000)
 {
     LogFilePath       = filePath;
     IsEnabled         = enabled;
     Ext               = ext;
     RotationLogFileKB = rotSizeKb;
     Flags             = trace;
 }
Пример #10
0
 public static void Trace(LogFlags flags, params Object[] obj)
 {
     try
     {
         Loggers[LogTypes.Trace].ForEach(x => x.Log(flags, obj));
     }
     catch (Exception ex)
     {
         Debug(ex);
     }
 }
Пример #11
0
 public static void Inform(LogFlags flags, params Object[] obj)
 {
     try
     {
         Loggers[LogTypes.Info].ForEach(x => x.Log(flags, obj));
     }
     catch (Exception ex)
     {
         Warn(ex);
     }
 }
Пример #12
0
 public static void Warn(LogFlags flags, params Object[] obj)
 {
     try
     {
         Loggers[LogTypes.Warning].ForEach(x => x.Log(flags, obj));
     }
     catch (Exception ex)
     {
         Error(ex);
     }
 }
Пример #13
0
 public static void Error(LogFlags flags, params Object[] obj)
 {
     try
     {
         Loggers[LogTypes.Error].ForEach(x => x.Log(flags, obj));
     }
     catch (Exception ex)
     {
         Fatal(ex);
     }
 }
Пример #14
0
        internal string FormatMessage(LogFlags flags, string message, bool timestamp)
        {
            StringBuilder final = new StringBuilder();
            StringBuilder tags  = new StringBuilder();

            foreach (string fname in GetFlagNames(flags))
            {
                tags.AppendFormat("[{0}]", fname);
            }
            final.AppendFormat("{0}{1}: {2}", timestamp ? String.Format("[{0}]", new DateTime().ToLocalTime().ToString()) : String.Empty, tags.ToString(), flags, message);
            return(final.ToString());
        }
Пример #15
0
        /// <summary>
        /// Configure the logging system.
        /// </summary>
        public static void Configure(LogFlags flags)
        {
            // Configure base system
            XmlConfigurator.Configure();

            // Log OpenGL method calls
            KhronosApi.RegisterApplicationLogDelegate(delegate(string format, object[] args) {
                _ProcedureLogger.Debug(format, args);
            });
            // Enabe procedure logging
            KhronosApi.LogEnabled = true;
        }
Пример #16
0
        public static void Info(LogFlags flags, params object[] args)
        {
#if ULINK
            uLink.Log.Info(uLink.NetworkLogFlags.Socket, args);
#elif ULINK_TOOL
            // TODO: add support for log levels in the tools
#if DEBUG
            uLink.ConsoleMain.Log(String.Concat(args));
#endif
#elif ULOBBY
            uLobby.Log.Info(uLobby.LogFlags.Network, args);
#endif
        }
Пример #17
0
        internal JournalLogger(string name, IExternalScopeProvider scopeProvider, JournalLoggerOptions options)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            Name          = name;
            ScopeProvider = scopeProvider;
            if (options.DropWhenBusy)
            {
                _additionalFlags |= LogFlags.DropWhenBusy;
            }
            _syslogIdentifier = options.SyslogIdentifier;
            _additionalFlags |= LogFlags.DontAppendSyslogIdentifier;
        }
Пример #18
0
 public LogFlagPipe(LogTypes type, LogFlags flags) : base(o =>
 {
     ProcessPipe <String, String> pipe = new EmptyPipe <String>();
     if (flags.HasFlag(LogFlags.PrefixLoggerType))
     {
         pipe = pipe.Connect(new ProcessPipe <String, String>(s => $"[{type}] {s}"));
     }
     if (flags.HasFlag(LogFlags.PrefixTimeStamp))
     {
         pipe = pipe.Connect(new ProcessPipe <String, String>(s => $"[{DateTime.Now:s}] {s}"));
     }
     if (flags.HasFlag(LogFlags.SuffixNewLine))
     {
         pipe = pipe.Connect(new ProcessPipe <String, String>(s => $"{s}{Environment.NewLine}"));
     }
     return(pipe.Process(o));
 }) { }
Пример #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="vLogs.Objects.LogObject"/> class with the specified sources, timestamp, flags, priority, indent and payload.
        /// </summary>
        /// <remarks>
        /// Individual sources may be null.
        /// </remarks>
        /// <param name="sources">Hierachically-descending sequence of named sources.</param>
        /// <param name="timestamp">Instant in time at which the object is emitted.</param>
        /// <param name="flags">Set of flags describing the object.</param>
        /// <param name="priority">Relative priority.</param>
        /// <param name="indent">Logical indentation level.</param>
        /// <param name="payloads">An enumeration of different payloads of the object.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when the given sources sequence or payloads enumeration are null.</exception>
        /// <exception cref="System.ArgumentException">Thrown when a given payload is of unknown type -or- two payloads are of the same type -or- when a payload is null -or- a source is null.</exception>
        public LogObject(IList<string> sources, DateTime timestamp, LogFlags flags, sbyte priority, byte indent, IEnumerable<IPayload> payloads)
        {
            if (sources == null)
                throw new ArgumentNullException("sources");
            if (payloads == null)
                throw new ArgumentNullException("payloads");

            this.Timestamp = timestamp;
            this.Flags = flags;
            this.Priority = priority;
            this.Indent = indent;

            for (int i = 0; i < sources.Count; i++)
                if (sources[i] == null)
                    throw new ArgumentException(string.Format("The list of sources contains a null element at index {0}.", i), "sources");

            this.Sources = new ReadOnlyCollection<string>(sources);

            var plds = payloads.ToArray();

            this.Payloads = new ReadOnlyCollection<IPayload>(plds);

            for (int i = 0; i < plds.Length; i++)
            {
                PayloadTypes pldt;

                try
                {
                    pldt = plds[i].GetType().GetPayloadType();
                }
                catch (ArgumentException x)
                {
                    throw new ArgumentException("Payloads enumeration contains a payload of unkown type.", x);
                }
                catch (NullReferenceException x)
                {
                    throw new ArgumentException("Payloads enumeration contains a null payload.", x);
                }

                if ((this.PayloadTypes & pldt) == 0)
                    this.PayloadTypes |= pldt;
                else
                    throw new ArgumentException("Payloads enumerations may not contain two payloads of the same type." + Environment.NewLine + "Duplicated type: " + pldt);
            }
        }
Пример #20
0
        public void Log(LogFlags flags, params Object[] args)
        {
            StringBuilder sb = new StringBuilder();
            ProcessPipe <Object, String> preparePipe = _prepareLogPipe.Connect(new LogFlagPipe(Type, flags));

            foreach (Object arg in args)
            {
                try
                {
                    sb.Append(preparePipe.Process(arg));
                }
                catch (Exception ex)
                {
                    BubbleException(flags, ex);
                }
            }

            _executeLogPipe.Process(sb.ToString());
        }
Пример #21
0
        private void Log(string message, LogFlags flag)
        {
            if ((Logging & flag) != flag)
            {
                return;
            }

            if ((Logging & LogFlags.Caller) == LogFlags.Caller)
            {
                var frame        = new StackTrace(true).GetFrame(2);
                var method       = frame.GetMethod();
                var callerClass  = method.DeclaringType;
                var callerMethod = method.Name;

                Debug.Log($"[Minerva]: {message}\nCaller: {callerClass}.{callerMethod}");
            }
            else
            {
                Debug.Log($"[Minerva]: {message}");
            }
        }
Пример #22
0
        private void LogAdd(string message, LogFlags flags = LogFlags.None)
        {
            if (fMain.IsInitialized == false)
            {
                return;
            }

            //add time
            if ((chkLogTime.IsChecked.Value == true) && (flags.HasFlag(LogFlags.noTime) == false))
            {
                message = DateTime.Now.ToString("yyyy-MM-dd HH\\:mm\\:ss.fff") + "> " + message;
            }

            //new line
            if (!flags.HasFlag(LogFlags.noReturn))
            {
                message += Environment.NewLine;
            }

            //write to file
            if (!flags.HasFlag(LogFlags.toFile))
            {
                lock (writeLock)
                    try
                    {
                        File.AppendAllText(logFileName, message);
                    }
                    catch (Exception e)
                    {
                        message += "[writeFileError]" + e.Message;
                    }
            }

            txtLog.AppendText(message);
            txtLog.ScrollToEnd();
        }
Пример #23
0
        /// <summary>
        /// Initializes the object with the given property values.
        /// </summary>
        /// <param name="manager">The manager which owns the object; must be non-null.</param>
        /// <param name="timestamp">The creation timestamp.</param>
        /// <param name="flags">Flags for logging the object.</param>
        /// <param name="priority">Relative priority of the object.</param>
        /// <param name="indent">Logical indentation of the object.</param>
        /// <param name="sources">An enumeration of sources of the object.</param>
        /// <param name="payloads">An enumeration of payloads of the object.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when the given manager object is null.</exception>
        /// <exception cref="System.ArgumentException">Thrown when an enumerated source is null -or- an enumerated payload is null -or- a given payload is of unknown type -or- two payloads are of the same type.</exception>
        protected FluentLogObject(IFluentManager manager, DateTime timestamp, LogFlags flags = Defaults.LogFlags, sbyte priority = Defaults.Priority, byte indent = Defaults.Indent, IEnumerable<string> sources = null, IEnumerable<IPayload> payloads = null)
        {
            if (manager == null)
                throw new ArgumentNullException("manager");

            this.Manager = manager;
            this.Timestamp = timestamp;
            this.Flags = flags;
            this.Priority = priority;
            this.Indent = indent;

            if (sources == null)
            {
                this.sources = new List<string>();
            }
            else
            {
                this.sources = new List<string>(sources);

                for (int i = 0; i < this.sources.Count; i++)
                    if (this.sources[i] == null)
                        throw new ArgumentException("The enumeration of sources contains a null element.", "sources");
            }

            this.Sources = new ReadOnlyCollection<string>(this.sources);

            if (payloads == null)
            {
                this.payloads = new List<IPayload>();
            }
            else
            {
                var plds = payloads.ToArray();

                for (int i = 0; i < plds.Length; i++)
                {
                    PayloadTypes pldt;

                    try
                    {
                        pldt = plds[i].GetType().GetPayloadType();
                    }
                    catch (ArgumentException x)
                    {
                        throw new ArgumentException("Payloads enumeration contains a payload of unkown type.", x);
                    }
                    catch (NullReferenceException x)
                    {
                        throw new ArgumentException("Payloads enumeration contains a null payload.", x);
                    }

                    if ((this.PayloadTypes & pldt) == 0)
                        this.PayloadTypes |= pldt;
                    else
                        throw new ArgumentException("Payloads enumerations may not contain two payloads of the same type." + Environment.NewLine + "Duplicated type: " + pldt);
                }

                this.payloads = new List<IPayload>(plds);
            }

            this.Payloads = new ReadOnlyCollection<IPayload>(this.payloads);
        }
Пример #24
0
        public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            if (!IsEnabled(logLevel))
            {
                return;
            }

            if (formatter == null)
            {
                throw new ArgumentNullException(nameof(formatter));
            }

            string message = formatter(state, exception);

            LogFlags flags = LogFlags.None;

            switch (logLevel)
            {
            case LogLevel.Trace:
            case LogLevel.Debug:
                flags = LogFlags.Debug; break;

            case LogLevel.Information:
                flags = LogFlags.Information; break;

            case LogLevel.Warning:
                flags = LogFlags.Warning; break;

            case LogLevel.Error:
                flags = LogFlags.Error; break;

            case LogLevel.Critical:
                flags = LogFlags.Critical; break;

            default:
                throw new ArgumentOutOfRangeException(nameof(logLevel));
            }
            flags |= _additionalFlags;

            if (!string.IsNullOrEmpty(message) || exception != null)
            {
                using (var logMessage = Journal.GetMessage())
                {
                    if (_syslogIdentifier != null)
                    {
                        logMessage.Append(JournalFieldName.SyslogIdentifier, _syslogIdentifier);
                    }
                    logMessage.Append(Logger, Name);
                    if (eventId.Id != 0 || eventId.Name != null)
                    {
                        logMessage.Append(EventId, eventId.Id);
                    }
                    if (exception != null)
                    {
                        logMessage.Append(Exception, exception.Message);
                        logMessage.Append(ExceptionType, exception.GetType().FullName);
                        logMessage.Append(ExceptionStackTrace, exception.StackTrace);
                        Exception innerException = exception.InnerException;
                        if (innerException != null)
                        {
                            logMessage.Append(InnerException, innerException.Message);
                            logMessage.Append(InnerExceptionType, innerException.GetType().FullName);
                            logMessage.Append(InnerExceptionStackTrace, innerException.StackTrace);
                        }
                    }
                    if (!string.IsNullOrEmpty(message))
                    {
                        logMessage.Append(JournalFieldName.Message, message);
                    }
                    var scopeProvider = ScopeProvider;
                    if (scopeProvider != null)
                    {
                        scopeProvider.ForEachScope((scope, msg) => AppendScope(scope, msg), logMessage);
                    }
                    if (state != null)
                    {
                        AppendState("STATE", state, logMessage);
                    }
                    Journal.Log(flags, logMessage);
                }
            }
        }
Пример #25
0
        /// <summary>
        /// Submit a log entry to the journal.
        /// </summary>
        public static unsafe LogResult Log(LogFlags flags, JournalMessage message)
        {
            Socket socket = GetJournalSocket();

            if (socket == null)
            {
                if (s_isSupported.Value)
                {
                    return(LogResult.NotAvailable);
                }
                else
                {
                    return(LogResult.NotSupported);
                }
            }

            if (message.IsEmpty)
            {
                return(LogResult.Success);
            }

            int priority = (int)flags & 0xf;

            if (priority != 0)
            {
                message.Append(JournalFieldName.Priority, priority - 1);
            }
            if (((flags & LogFlags.DontAppendSyslogIdentifier) == LogFlags.None) &&
                SyslogIdentifier != null)
            {
                message.Append(JournalFieldName.SyslogIdentifier, SyslogIdentifier);
            }

            List <ArraySegment <byte> > data = message.GetData();
            int dataLength = data.Count;

            if (dataLength > MaxIovs)
            {
                // We should handle this the same way as EMSGSIZE, which we don't handle atm.
                ErrorWhileLogging("size exceeded");
                return(LogResult.Size);
            }
            Span <IOVector> iovs    = stackalloc IOVector[dataLength];
            Span <GCHandle> handles = stackalloc GCHandle[dataLength];

            for (int i = 0; i < data.Count; i++)
            {
                handles[i]     = GCHandle.Alloc(data[i].Array, GCHandleType.Pinned);
                iovs[i].Base   = handles[i].AddrOfPinnedObject();
                iovs[i].Length = new IntPtr(data[i].Count);
            }
            int sendmsgFlags = 0;

            if ((flags & LogFlags.DropWhenBusy) != 0)
            {
                sendmsgFlags |= MSG_DONTWAIT;
            }
            LogResult result = LogResult.Success;

            fixed(IOVector *pIovs = &MemoryMarshal.GetReference(iovs))
            {
                bool loop;

                do
                {
                    loop = false;
                    msghdr msg;
                    msg.msg_iov    = pIovs;
                    msg.msg_iovlen = (SizeT)dataLength;
                    int rv = sendmsg(socket.Handle.ToInt32(), &msg, sendmsgFlags).ToInt32();
                    if (rv < 0)
                    {
                        int errno = Marshal.GetLastWin32Error();
                        if (errno == EINTR)
                        {
                            loop = true;
                        }
                        else if (errno == EAGAIN)
                        {
                            result = LogResult.Busy;
                        }
                        else
                        {
                            result = LogResult.UnknownError;
                            ErrorWhileLogging($"errno={errno}");
                        }
                    }
                } while (loop);
            }

            for (int i = 0; i < handles.Length; i++)
            {
                handles[i].Free();
            }
            return(result);
        }
Пример #26
0
 public static void Fatal(LogFlags flags, params Object[] obj)
 {
     Loggers[LogTypes.Fatal].ForEach(x => x.Log(flags, obj));
 }
Пример #27
0
        IFluentLogObject IFluentLogObject.WithExtraFlags(LogFlags flags)
        {
            this.Flags |= flags;

            return this;
        }
Пример #28
0
        IFluentLogObject IFluentLogObject.WithFlags(LogFlags flags)
        {
            this.Flags = flags;

            return this;
        }
Пример #29
0
        IFluentLogObject IFluentLogObject.WithoutFlags(LogFlags flags)
        {
            this.Flags &= ~flags;

            return this;
        }
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="vLogs.Fluent.FluentLogObject"/> class with the specified fluent logging manager, sources enumeration, logging flags, priority and indent.
 /// </summary>
 /// <param name="manager">The fluent logging manager which owns the current object.</param>
 /// <param name="sources">An enumeration of sources for the log object.</param>
 /// <param name="flags">optional; Flags for logging the object.</param>
 /// <param name="priority">optional; Relative priority of the object.</param>
 /// <param name="indent">optional; Logical indentation of the object.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when the given manager object is null.</exception>
 /// <exception cref="System.ArgumentException">Thrown when an enumerated source is null.</exception>
 public FluentLogObject(IFluentManager manager, IEnumerable<string> sources, LogFlags flags = Defaults.LogFlags, sbyte priority = Defaults.Priority, byte indent = Defaults.Indent)
     : this(manager, DateTime.Now, flags, priority, indent, sources)
 {
 }
Пример #31
0
 public LogRecord(DateTimeOffset dateTime, object?data, LogPriority priority = LogPriority.Debug, LogFlags flags = LogFlags.None, string?tag = null)
 {
     this.TimeStamp = dateTime;
     this.Data      = data;
     this.Priority  = priority;
     this.Flags     = flags;
     this.Tag       = tag;
     this.Guid      = System.Guid.NewGuid().ToString("N");
 }
Пример #32
0
        // methods
        /// <summary>
        /// Writes a log entry.
        /// </summary>
        /// <param name="severity">The severity level</param>
        /// <param name="message">The text</param>
        /// <param name="exception">The exception</param>
        /// <param name="date">The date</param>
        /// <param name="application">The application</param>
        /// <param name="category">The category</param>
        /// <param name="flags">The flags</param>
        /// <returns>Is written or not</returns>
        public bool Write(LogLevel severity, string message, Exception exception = null, LogFlags? flags = LogFlags.None, DateTimeOffset? date = null, string category = null, string threadFrom = null, string application = null)
        {
            var context = LoggerContext.Current;

            return context.Write(new LogEntry()
            {
                Application = application ?? context.Application,
                ThreadFrom = threadFrom ?? Thread.CurrentThread.Name,
                Category = category ?? this.category,
                Date = date ?? DateTimeOffset.UtcNow,
                Exception = exception,
                Flags = flags ?? LogFlags.None,
                Message = message,
                Severity = severity
            });
        }
Пример #33
0
 public LogRecord(object?data, LogPriority priority = LogPriority.Debug, LogFlags flags = LogFlags.None, string?tag = null) : this(0, data, priority, flags, tag)
 {
 }
Пример #34
0
 public static void Post(object?obj, LogPriority priority = LogPriority.Debug, string kind = LogKind.Default, LogFlags flags = LogFlags.None, string?tag = null)
 => Router?.PostLog(new LogRecord(obj, priority, flags, tag), kind);
Пример #35
0
 public LogRecord(long tick, object?data, LogPriority priority = LogPriority.Debug, LogFlags flags = LogFlags.None, string?tag = null)
     : this(tick == 0 ? ((data as ILogRecordTimeStamp)?.TimeStamp ?? DateTimeOffset.Now) : Time.Tick64ToDateTimeOffsetLocal(tick), data, priority, flags, tag)
 {
 }
Пример #36
0
 public Logger(String name, LogFlags flag = LogFlags.StdoutOnly, String filename = "log.txt")
 {
     this.flags    = flag;
     this.filename = filename;
     this.name     = name;
 }
Пример #37
0
		/// <summary>
		/// Configure the logging system.
		/// </summary>
		public static void Configure(LogFlags flags)
		{
			// Configure base system
			XmlConfigurator.Configure();

			// Log OpenGL method calls
			KhronosApi.RegisterApplicationLogDelegate(delegate(string format, object[] args) {
				_ProcedureLogger.Debug(format, args);
			});
			// Enabe procedure logging
			KhronosApi.LogEnabled = true;
		}
Пример #38
0
 public static void PrintConsole(object?obj, bool noConsole = false, LogPriority priority = LogPriority.Info, string?tag = null, LogFlags flags = LogFlags.None)
 => Post(obj, priority, flags: flags | (noConsole ? LogFlags.NoOutputToConsole : LogFlags.None), tag: tag);