public static Data PackageAsPayloadData( IRollbarConfig rollbarConfig, ErrorLevel level, object obj, IDictionary <string, object> custom = null ) { if (rollbarConfig.LogLevel.HasValue && level < rollbarConfig.LogLevel.Value) { // nice shortcut: return(null); } Data data = obj as Data; if (data != null) { data.Level = level; return(data); } Body body = obj as Body; if (body == null) { body = RollbarUtil.PackageAsPayloadBody(obj, ref custom); } data = new Data(rollbarConfig, body, custom); data.Level = level; return(data); }
public static Body PackageAsPayloadBody(object bodyObject, ref IDictionary <string, object> custom) { System.Exception exception = bodyObject as System.Exception; if (exception != null) { RollbarUtil.SnapExceptionDataAsCustomData(exception, ref custom); return(new Body(exception)); } string messageString = bodyObject as string; if (messageString != null) { return(new Body(new Message(messageString))); } ITraceable traceable = bodyObject as ITraceable; if (traceable != null) { return(new Body(traceable.TraceAsString())); } return(new Body(new Message(bodyObject.ToString()))); }
private void Enqueue( object dataObject, ErrorLevel level, IDictionary <string, object> custom, DateTime?timeoutAt = null, SemaphoreSlim signal = null ) { lock (this._syncRoot) { var data = RollbarUtil.PackageAsPayloadData(this.Config, level, dataObject, custom); //new Data(this._config, body, custom); var payload = new Payload(this._config.AccessToken, data, timeoutAt, signal); DoSend(payload); } }