protected override void Write(UnsafeString message)
        {
            var log           = ((ServiceStackLoggingTypeSource)TypeSource).Log;
            var messageString = message.ToString();

            switch (Level)
            {
            case LogLevel.None:
                break;

            case LogLevel.Trace:
            case LogLevel.Debug:
                if (Exception == null)
                {
                    log.Debug(messageString);
                }
                else
                {
                    log.Debug(messageString, Exception);
                }

                break;

            case LogLevel.Info:
                if (Exception == null)
                {
                    log.Info(messageString);
                }
                else
                {
                    log.Info(messageString, Exception);
                }

                break;

            case LogLevel.Warning:
                if (Exception == null)
                {
                    log.Warn(messageString);
                }
                else
                {
                    log.Warn(messageString, Exception);
                }

                break;

            case LogLevel.Error:
                if (Exception == null)
                {
                    log.Error(messageString);
                }
                else
                {
                    log.Error(messageString, Exception);
                }

                break;

            case LogLevel.Critical:
                if (Exception == null)
                {
                    log.Fatal(messageString);
                }
                else
                {
                    log.Fatal(messageString, Exception);
                }

                break;
            }
        }
Example #2
0
 /// <inheritdoc />
 protected override void Write(UnsafeString message)
 {
     Log.Write(TranslateLevel(this.Level), "PostSharp", this, null, this.Exception, LogWriteMode.Queued,
               null, this.TypeSource.Role + "." + this.RecordKind.ToString(), message.ToString(), null);
 }