diff --git a/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java b/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java index 6cbf5d272..75e73fa7e 100644 --- a/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java +++ b/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java @@ -88,8 +88,7 @@ public DocSection section() { utils.addItem(diBuilder.getDocItem("docker/container-remove-by-name", false)); utils.addItem(diBuilder.getDocItem("docker/container-status-by-name", false)); utils.addItem(diBuilder.getDocItem("docker/container-exec-by-name", false)); - utils.addItem(diBuilder.getDocItem("docker/container-log", false)); - utils.addItem(diBuilder.getDocItem("docker/container-has-log-msg", false)); + utils.addItem(diBuilder.getDocItem("docker/container-logs", false)); utils.addItem(diBuilder.getDocItem("docker/container-purge-by-name", false)); utils.addItem(diBuilder.getDocItem("docker/container-image-info-by-name", false)); diff --git a/src/main/resources/com/github/jlangch/venice/docker.venice b/src/main/resources/com/github/jlangch/venice/docker.venice index efab42536..94b165ca2 100644 --- a/src/main/resources/com/github/jlangch/venice/docker.venice +++ b/src/main/resources/com/github/jlangch/venice/docker.venice @@ -389,8 +389,7 @@ "docker/container-remove-by-name" "docker/container-status-by-name" "docker/container-exec-by-name" - "docker/container-log" - "docker/container-has-log-msg" + "docker/container-logs" "docker/container-purge-by-name" "docker/container-image-info-by-name" ) :spec { :options { :detach [:optional #{true, false}] @@ -1031,8 +1030,7 @@ ;; - docker/container-remove-by-name ;; - docker/container-status-by-name ;; - docker/container-exec-by-name -;; - docker/container-log -;; - docker/container-has-log-msg +;; - docker/container-logs ;; - docker/container-purge-by-name ;; - docker/container-image-info-by-name ;; ----------------------------------------------------------------------------- @@ -1171,7 +1169,7 @@ "docker/container-stop-by-name" "docker/container-remove-by-name" "docker/container-status-by-name" - "docker/container-log" ) } + "docker/container-logs" ) } container-start-by-name [name] @@ -1205,7 +1203,7 @@ "docker/container-stop-by-name" "docker/container-remove-by-name" "docker/container-status-by-name" - "docker/container-log" ) } + "docker/container-logs" ) } container-stop-by-name @@ -1341,7 +1339,7 @@ "docker/run" "docker/container-running-with-name?" "docker/container-exec-by-name" - "docker/container-log" ) } + "docker/container-logs" ) } container-exec-by-name [name] @@ -1355,74 +1353,35 @@ (defn ^{ :arglists '( - "(docker/container-log name)" - "(docker/container-log name since)") + "(docker/container-logs name & options)") :doc """ Returns the container logs. - """ - :examples '( - """ - (docker/container-log "myapp"9 - """, - """ - (docker/container-log "myapp" "2m") - """ ) - :see-also '( - "docker/run" - "docker/container-running-with-name?" - "docker/container-has-log-msg" ) } - - container-log - ([name] - (container-log name nil)) - - ([name since] - (let [container (first (container-find-by-name name)) - id (get container "ID") - status (get container "State")] - (assert (= status "running") - "There is no container running with the name \"~{name}\"!") - (if (nil? since) (docker/logs id) (docker/logs id :since since))))) - - -(defn - ^{ :arglists '( - "(docker/container-has-log-msg name msg)" - "(docker/container-has-log-msg name msg tail)") - :doc """ - Returns true if the container logs has message that matches the - regex 'msg' and is newer than the optional 'since' timestamp. + Options: - 'tail': the number of lines to show from the end of the logs + | :tail n | Number of lines to show from the end of the logs | + | :since ts | Show logs since timestamp or relative (e.g. "42m" for 42 minutes) | + | :until ts | Show logs until timestamp or relative (e.g. "42m" for 42 minutes) | + | :follow {true, false} | Follow log output | + | :details {true, false} | Show extra details provided to logs | """ :examples '( """ - (docker/container-has-log-msg "myapp" - #".*is ready for business. Have fun.*" - 10) + (docker/container-logs "myapp") + """, + """ + (docker/container-logs "myapp" :since "2m") """ ) :see-also '( "docker/run" - "docker/container-running-with-name?" - "docker/container-log" ) } - - container-has-log-msg + "docker/logs" + "docker/container-running-with-name?" ) } - ([name msg] - (container-has-log-msg name msg nil)) + container-logs [name & options] - ([name msg tail] - (let [container (first (container-find-by-name name)) - id (get container "ID") - status (get container "State")] - (assert (= status "running") - "There is no container running with the name \"~{name}\"!") - (->> (if (nil? tail) (docker/logs id) (docker/logs id :tail tail)) - (str/split-lines) - (filter #(match? % msg)) - (count) - (pos?))))) + (let [container (first (container-find-by-name name)) + id (get container "ID")] + (apply docker/logs id options)))