(ns ^{:added "2.0.0" :author "Pedro Santos"}
  obb-rules.logger
  "Specific logger that can be turned on and off"
  (:require [obb-rules.simplifier :as simplify]))

(def ^:dynamic *verbose* false)

(defmacro log
  "Logs the given data"
  [& args]
  `(when *verbose*
    (println ~@args)))

(defn ai-turn
  "Logs ai-turn header"
  [ai-name game]
  (log "## ~~~~~~~~~~~~~~~~~~~~~~")
  (log "## AI Turn:" ai-name)
  (log "Game:")
  (log (simplify/clean-result {:board game})))

(defmacro with-verbose
  "Runs the given code in verbose mode"
  [& body]
  `(binding [*verbose* true]
    ~@body))

(defn ai-option
  "Logs an AI option"
  [option]
  (log (:actions option))
  (log "\tValue:" (:value option)
       "(" (:old-value option) ")"
       "Cost:" (:cost option)))

(ns ^{:added "2.0.0" :author "Pedro Santos"}
  obb-rules.logger
  "Specific logger that can be turned on and off"
  (:require [obb-rules.simplifier :as simplify]))

(def ^:dynamic *verbose* false)

#?(:clj
  (defmacro log
    "Logs the given data"
    [& args]
    `(when *verbose*
      (println ~@args))))

#?(:cljs
  (defn log
    "Logs the given data"
    [& args]
    (when *verbose*
      (apply println args))))

(defn ai-turn
  "Logs ai-turn header"
  [ai-name game]
  (log "## ~~~~~~~~~~~~~~~~~~~~~~")
  (log "## AI Turn:" ai-name)
  (log "Game:")
  (log (simplify/clean-result {:board game})))

(defmacro with-verbose
  "Runs the given code in verbose mode"
  [& body]
  `(binding [*verbose* true]
    ~@body))

(defn ai-option
  "Logs an AI option"
  [option]
  (log (:actions option))
  (log "\tValue:" (:value option)
       "(" (:old-value option) ")"
       "Cost:" (:cost option)))

Use log fn instead of macro on cljs
Use log fn instead of macro on cljs

orionsbelt-battlegrounds/obb-rules,orionsbelt-battlegrounds/obb-rules,orionsbelt-battlegrounds/obb-rules