Skip to content

Commit de68632

Browse files
committed
Switch to tools.logging
1 parent 8626e66 commit de68632

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
<artifactId>clojure-contrib</artifactId>
9898
<version>1.2.0</version>
9999
</dependency>
100+
<dependency>
101+
<groupId>org.clojure</groupId>
102+
<artifactId>tools.logging</artifactId>
103+
<version>0.1.2</version>
104+
</dependency>
100105
<dependency>
101106
<groupId>com.jcraft</groupId>
102107
<artifactId>jsch</artifactId>

src/clj_ssh/keychain.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"Primitive keychain support for clj-ssh. Only implemented on OSX at the
33
moment."
44
(:require
5-
[clojure.contrib.logging :as logging]
5+
[clojure.tools.logging :as logging]
66
[clojure.contrib.shell :as shell]))
77

88
(defn ask-passphrase [path]

src/clj_ssh/ssh.clj

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Licensed under EPL (http://www.eclipse.org/legal/epl-v10.html)"
4242
(:require
4343
[clj-ssh.keychain :as keychain]
4444
[clojure.contrib.condition :as condition]
45-
[clojure.contrib.logging :as logging]
45+
[clojure.tools.logging :as logging]
4646
[clojure.contrib.reflect :as reflect]
4747
[clojure.java.io :as io]
4848
[clojure.string :as string])
@@ -70,7 +70,7 @@ Licensed under EPL (http://www.eclipse.org/legal/epl-v10.html)"
7070
(>= level log-level))
7171
(log
7272
[_ level message]
73-
(logging/log (@ssh-log-levels level) message nil "clj-ssh.ssh")))
73+
(logging/log "clj-ssh.ssh" (@ssh-log-levels level) nil message)))
7474

7575
(JSch/setLogger (SshLogger. com.jcraft.jsch.Logger/DEBUG))
7676

@@ -123,8 +123,7 @@ Licensed under EPL (http://www.eclipse.org/legal/epl-v10.html)"
123123
([private-key-path public-key-path]
124124
(make-identity *ssh-agent* private-key-path public-key-path))
125125
([^JSch agent ^String private-key-path ^String public-key-path]
126-
(logging/trace
127-
(format "Make identity %s %s" private-key-path public-key-path))
126+
(logging/tracef "Make identity %s %s" private-key-path public-key-path)
128127
(reflect/call-method
129128
com.jcraft.jsch.IdentityFile 'newInstance [String String JSch]
130129
nil private-key-path public-key-path agent)))
@@ -413,8 +412,8 @@ cmd specifies a command to exec. If no cmd is given, a shell is started and inp
413412
Options are
414413
415414
:in specifies input to the remote shell. A string or a stream.
416-
:out specify :stream to obtain a an [inputstream shell],
417-
specify :bytes to obtain a byte array,
415+
:out specify :stream to obtain a an [inputstream shell]
416+
specify :bytes to obtain a byte array
418417
or specify a string with an encoding specification for a
419418
result string. In the case of :stream, the shell can
420419
be polled for connected status.
@@ -613,7 +612,7 @@ Options are
613612
[out in cmd-string]
614613
(.write out (.getBytes cmd-string))
615614
(.flush out)
616-
(logging/trace (format "Sent command %s" cmd-string))
615+
(logging/tracef "Sent command %s" cmd-string)
617616
(scp-receive-ack in)
618617
(logging/trace "Received ACK"))
619618

@@ -624,14 +623,13 @@ Options are
624623
buffer (byte-array buffer-size)]
625624
(let [cmd (loop [offset 0]
626625
(let [n (.read in buffer offset (- buffer-size offset))]
627-
(logging/trace
628-
(format
629-
"scp-receive-command: %s"
630-
(String. buffer 0 (+ offset n))))
626+
(logging/tracef
627+
"scp-receive-command: %s"
628+
(String. buffer 0 (+ offset n)))
631629
(if (= \newline (char (aget buffer (+ offset n -1))))
632630
(String. buffer 0 (+ offset n))
633631
(recur (+ offset n)))))]
634-
(logging/trace (format "Received command %s" cmd))
632+
(logging/tracef "Received command %s" cmd)
635633
(scp-send-ack out)
636634
(logging/trace "Sent ACK")
637635
cmd)))
@@ -640,7 +638,7 @@ Options are
640638
"Send acknowledgement to the specified output stream"
641639
[send recv file {:keys [mode buffer-size preserve]
642640
:or {mode 0644 buffer-size 1492 preserve false}}]
643-
(logging/trace (format "Sending %s" (.getAbsolutePath file)))
641+
(logging/tracef "Sending %s" (.getAbsolutePath file))
644642
(when preserve
645643
(scp-send-command
646644
send recv
@@ -658,7 +656,7 @@ Options are
658656
(defn- scp-copy-dir
659657
"Send acknowledgement to the specified output stream"
660658
[send recv dir {:keys [dir-mode] :or {dir-mode 0755} :as options}]
661-
(logging/trace (format "Sending directory %s" (.getAbsolutePath dir)))
659+
(logging/trace "Sending directory %s" (.getAbsolutePath dir))
662660
(scp-send-command
663661
send recv
664662
(format "D%04o 0 %s" dir-mode (.getName dir)))
@@ -721,7 +719,7 @@ Options are
721719
(defn scp-sink-file
722720
"Sink a file"
723721
[send recv file mode length {:keys [buffer-size] :or {buffer-size 2048}}]
724-
(logging/trace (format "Sinking %d bytes to file %s" length (.getPath file)))
722+
(logging/tracef "Sinking %d bytes to file %s" length (.getPath file))
725723
(let [buffer (byte-array buffer-size)]
726724
(with-open [file-stream (java.io.FileOutputStream. file)]
727725
(loop [length length]
@@ -792,14 +790,14 @@ Options are
792790
(connect session))
793791
(let [[in send] (streams-for-in)
794792
cmd (format "scp %s -t %s" (:remote-flags opts "") remote-path)
795-
_ (logging/trace (format "scp-to: %s" cmd))
793+
_ (logging/tracef "scp-to: %s" cmd)
796794
[exec recv] (ssh-exec session cmd in :stream opts)]
797-
(logging/trace
798-
(format "scp-to %s %s" (string/join " " local-paths) remote-path))
795+
(logging/tracef
796+
"scp-to %s %s" (string/join " " local-paths) remote-path)
799797
(logging/trace "Receive initial ACK")
800798
(scp-receive-ack recv)
801799
(doseq [file files]
802-
(logging/trace (format "scp-to: from %s" (.getPath file)))
800+
(logging/tracef "scp-to: from %s" (.getPath file))
803801
(if (.isDirectory file)
804802
(scp-copy-dir send recv file opts)
805803
(scp-copy-file send recv file opts)))
@@ -864,10 +862,10 @@ Options are
864862
(filter val)
865863
(map (fn [k v] (k flags))))))
866864
(string/join " " remote-paths))
867-
_ (logging/trace (format "scp-from: %s" cmd))
865+
_ (logging/tracef "scp-from: %s" cmd)
868866
[exec recv] (ssh-exec session cmd in :stream opts)]
869-
(logging/trace
870-
(format "scp-from %s %s" (string/join " " remote-paths) local-path))
867+
(logging/tracef
868+
"scp-from %s %s" (string/join " " remote-paths) local-path)
871869
(scp-send-ack send)
872870
(logging/trace "Sent initial ACK")
873871
(scp-sink send recv file nil opts)

0 commit comments

Comments
 (0)