Support dates from clojurescript

Bumped version 0.1.8
parent 5f61b59e
......@@ -3,7 +3,43 @@ All notable changes to this project will be documented in this file. This change
## [Unreleased]
## [0.1.8] - 2019-05-15
### Fixed
- Handling of dates in ClojureScript
## [0.1.7] - 2019-05-14
### Added
- ClojureScript support
## [0.1.6] - 2018-10-29
### Fixed
- Filter out fields that are not known by NSD ELK schema
## [0.1.4] - 2018-10-26
### Added
- Logging context can hold any value
## [0.1.3] - 2018-10-02
### Fixed
- Configurable log format fn
- All fields are configurable
## [0.0.2] - 2018-09-21
### Fixed
- Possibillity to push maven artifacts
## [0.0.1] - 2018-09-21
### Added
- Wraps most common Timbre functions.
- Pre configured setup for development and NSD elk logging
[Unreleased]: https://gitlab.nsd.no/clojure/envelope/compare/0.1.8...HEAD
[0.1.8]: https://gitlab.nsd.no/clojure/envelope/compare/0.1.7...0.1.8
[0.1.7]: https://gitlab.nsd.no/clojure/envelope/compare/0.1.6...0.1.7
[0.1.6]: https://gitlab.nsd.no/clojure/envelope/compare/0.1.4...0.1.6
[0.1.4]: https://gitlab.nsd.no/clojure/envelope/compare/0.1.3...0.1.4
[0.1.3]: https://gitlab.nsd.no/clojure/envelope/compare/0.0.2...0.1.3
[0.0.2]: https://gitlab.nsd.no/clojure/envelope/compare/0.0.1...0.0.2
[0.0.1]: https://gitlab.nsd.no/clojure/envelope/releases/tag/v0.0.1
......@@ -33,7 +33,7 @@ your consumers worry about formatting and appenders and all that jazz.
If your project is an application, add `Envelope` to your dependency graph:
```clojure
[no.nsd/envelope "0.1.7"]
[no.nsd/envelope "0.1.8"]
```
And use it like this:
......@@ -60,11 +60,11 @@ according to the NSD ELK schema. To use it, you will need to require both
Envolope and Timbre:
```clojure
[no.nsd/envelope "0.1.7"]
[com.taoensso/timbre "4.10.0"]
[no.nsd/envelope "0.1.8"]
```
and then use it like this:
and then use it like this (note that timbre is required. There is no need to
mention it in your deps, since it will be pulled by Envelope):
```clojure
......
(defproject no.nsd/envelope "0.1.7"
(defproject no.nsd/envelope "0.1.8"
:description "A thin wrapper around taoensso.timbre with built in settings for logging to NSD's ELK stack"
:url "https://gitlab.nsd.no/clojure/envelope"
:license {:name "Eclipse Public License"
......
......@@ -18,13 +18,17 @@
#?(:clj (json/write-str data)
:cljs (.stringify js/JSON (clj->js data))))
(comment
#_(.toISOString (new js/Date)))
(defn nsd-logstash-format-fn [config data]
"NSD format, compliant with https://gitlab.nsd.no/nsd-commons/log-schema"
(let [{:keys [level ?err msg_ ?ns-str ?file hostname_
timestamp_ ?line context]} data
ts #?(:cljs (.toISOString (new js/Date))
:default (force timestamp_))
output-data (cond->
{"@timestamp" (force timestamp_)
{"@timestamp" ts
:serviceName (force (:service-name config))
:serviceVersion (force (:service-version config))
:schemaVersion (force "v3")
......@@ -70,9 +74,15 @@
(defn local-console-format-fn [data]
"A simpler log format, suitable for readable logs during development. colorized stacktraces"
(let [{:keys [level ?err msg_ ?ns-str ?file hostname_
timestamp_ ?line context]} data]
timestamp_ ?line context]} data
ts #?(:cljs (let [d (new js/Date)]
(str (.getHours d) ":"
(.getMinutes d) ":"
(.getSeconds d) "."
(.getMilliseconds d)))
:default (force timestamp_))]
(cond->
(str (force timestamp_)
(str ts
(when (:x-request-id context)
(str " ["
(:x-request-id context)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment