replikativ / datahike

A fast, immutable, distributed & compositional Datalog engine for everyone.
https://datahike.io
Eclipse Public License 1.0
1.63k stars 97 forks source link

[Bug]: CLI: some warnings are being output to stdout #694

Closed acobster closed 1 month ago

acobster commented 1 month ago

What version of Datahike are you using?

0.6.1576 (CLI)

What version of Java are you using?

Whatever was used to build dthk v0.6.1576

What operating system are you using?

Ubuntu 22.04

What database EDN configuration are you using?

{:keep-history? true
 :store
 {:backend :file
  :path "/home/tamayo/projects/bread-cms/dthk.db"
  :config {:in-place? true}}
 :attribute-refs? true
 :schema-flexibility :write

 ;; These are part of an integration and are included here for completeness:
 :force? true
 :recreate? true
 :db/type :datahike-cli
 :cli/dthk-path "/home/tamayo/bin/dthk"
 :cli/config-path "/home/tamayo/projects/bread-cms/dthk.edn"}

Describe the bug

Some warnings are getting printed to stdout instead of stderr:

$ dthk query "[:find ?e . :in $ :where [?e :bad/attr]]" db:dthk.edn 2>/dev/null
2024-09-19T07:18:41.583Z toast WARN [datahike.db:?] - Attribute :bad/attr has not been found in database
60
$ dthk query "[:find ?e . :in $ :where [?e :bad/attr]]" db:dthk.edn >/dev/null
$

What is the expected behaviour?

I expect all warnings/errors to print to stderr, so I can reliably parse results as EDN (and check for warnings separately).

$ dthk query "[:find ?e . :in $ :where [?e :bad/attr]]" db:dthk.edn 2>/dev/null
60
$ dthk query "[:find ?e . :in $ :where [?e :bad/attr]]" db:dthk.edn >/dev/null
2024-09-19T07:18:41.583Z toast WARN [datahike.db:?] - Attribute :bad/attr has not been found in database

How can the behaviour be reproduced?

Run the above command with latest CLI :)

whilo commented 1 month ago

Thank you for reporting, I will take a look. I think this might be a problem with how the logging library works and not directly a fault in the CLI, https://github.com/replikativ/datahike/blob/main/src/datahike/cli.clj.