yuya373 / emacs-slack

slack client for emacs
1.11k stars 117 forks source link

Suppress message logs #514

Open wandersoncferreira opened 4 years ago

wandersoncferreira commented 4 years ago

Hi, thanks for all the work in this library. I am heavily relying on it and its great.

I searched in the docs and the source-code and was not clear to me how can I suppress some of these log messages:

Download Failed. STATUS: exit, EVENT: exited abnormally with code 28
, URL: https://avatars.slack-edge.com/2020-02-04/935390241876_185310dd0246ecb18b85_32.png, NAME: /tmp/ccafde64d91e1b9ca81b79ee33aed07e.png, OUTPUT: curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Cocurl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
nnection timed out
curl: (28) Failedcurl: (28) Failed to connect to i1.wp.com port 443: Connection timed out
curl: (28) Failed to connect to i1.wp.com port 443: Connection timed out
 to connect to i1.wp.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to i2.wp.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out
curl: (28) Failed to connect to avatars.slack-edge.com port 443: Connection timed out

Thanks!

prosoitos commented 1 year ago

I've been having the same problem for months, so I finally looked into the source code. It appeared that these error messages are triggered by the function slack-curl-downloader in slack.request.el.

To stop having them, I redefined that function in my init file and removed the message. Since I use use-package, I have this:

(use-package slack
  :config
  (cl-defun slack-curl-downloader (url name &key (success nil) (error nil) (token nil))
    (cl-labels
    ((sentinel (proc event)
                   (cond
                    ((string-equal "finished\n" event)
                     (when (functionp success) (funcall success)))
                    (t
                     (let ((status (process-status proc))
                           (output (with-current-buffer (process-buffer proc)
                                     (buffer-substring-no-properties (point-min)
                                                                     (point-max)))))
                       (if (functionp error)
                           (funcall error status output url name))
               (if (file-exists-p name)
                           (delete-file name))
               (delete-process proc))))))
      (let* ((url-obj (url-generic-parse-url url))
         (need-token-p (and url-obj
                (string-match-p "slack" (url-host url-obj))))
         (proc (apply #'start-process
                          "slack-curl-downloader"
                          "slack-curl-downloader"
                          (executable-find "curl")
                          "--silent"
                          "--show-error"
                          "--fail"
                          "--location"
                          "--output" name
                          "--url" url
                          (when (and token need-token-p (string-prefix-p "https" url))
                            `("-H" ,(format "Authorization: Bearer %s" token))))))
    (set-process-sentinel proc #'sentinel)))))

This finally solved this ongoing annoyance.

I hope this helps.