Skip to content

Commit

Permalink
default CS logger prints directly to standard output
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Waeselynck committed Oct 19, 2017
1 parent b73d269 commit f7a5859
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. This change
## [Unreleased]
### Added
- Basic example-based tests for spy and brk
### Fixed
- default CS logger prints directly to standard output so as not to get mixed with emitted JavaScript.

## 0.1.2 - 2017-10-18
## Changed
Expand Down
16 changes: 11 additions & 5 deletions src/sc/api/logging.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@
(defn- source-info [cs]
(str (get cs :sc.cs/file "(Unknown file)") ":" (:sc.cs/line cs)))

(defn- portable-println
[s]
#?(:clj (.println System/out ^String s)
:cljs (.log js/console s)))

(defn log-cs
[prefix cs]
(println prefix
(str "<" (:sc.cs/id cs) ">")
(source-info cs)
"\n "
(str "At Code Site " (:sc.cs/id cs) ", will save scope with locals " (pr-str (:sc.cs/local-names cs)))))
(portable-println
(str
prefix " <" (:sc.cs/id cs) "> "
(source-info cs) " "
"\n "
(str "At Code Site " (:sc.cs/id cs) ", will save scope with locals " (pr-str (:sc.cs/local-names cs))))))

(register-cs-logger
::log-spy-cs
Expand Down

0 comments on commit f7a5859

Please sign in to comment.