Misc general-purpose utils.
Misc general-purpose utils.
(get-int x)
Returns given input (number or string) coerced to a Long (Clojure's standard integer type), otherwise returns nil.
Returns given input (number or string) coerced to a Long (Clojure's standard integer type), otherwise returns nil.
(get-sys-val id)
(get-sys-val id default)
If the named JVM system property or environment variable exists, returns it as a string. Otherwise returns an optional default value (if provided), or throws.
Useful as a way to prevent hard-coding config!
If the named JVM system property or environment variable exists, returns it as a string. Otherwise returns an optional default value (if provided), or throws. Useful as a way to prevent hard-coding config!
(logmsg logcode ?msg)
(logmsg logcode ?msg ?data-map)
Returns a formatted log string like: "[logcode=<x>] msg="<msg>", <data-map-key1>="<data-map-val1>", ...
Useful for logging stuff to Splunk in a way that Splunk can ~easily index.
Returns a formatted log string like: "[logcode=<x>] msg="<msg>", <data-map-key1>="<data-map-val1>", ... Useful for logging stuff to Splunk in a way that Splunk can ~easily index.
(map->splunk-str m)
Given a map, returns a string using Splunk-style key-value pairs like "key1=value1, key2=value2, key3=value3".
These kinds of key-value pairs are detected by Splunk and can be used for automatic filtering, etc.
Given a map, returns a string using Splunk-style key-value pairs like "key1=value1, key2=value2, key3=value3". These kinds of key-value pairs are detected by Splunk and can be used for automatic filtering, etc.
(read-sys-val id)
(read-sys-val id default)
Like get-sys-val
but will read system properties
or environment variables as edn strings.
Can return any type, incl. keywords, longs, arbitrary data structures, etc.
Useful as a way to prevent hard-coding config!
Like `get-sys-val` but will _read_ system properties or environment variables as edn strings. Can return any type, incl. keywords, longs, arbitrary data structures, etc. Useful as a way to prevent hard-coding config!
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close