Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add named config overrides #659

Merged
merged 7 commits into from
Jul 26, 2022

Conversation

jsimnz
Copy link
Member

@jsimnz jsimnz commented Jul 23, 2022

Relevant issue(s)

Resolves #413

note: This is a duplicate of #656 intentionally as there was some issue with the Github Actions not being triggered correctly

Description

Supports a new format for configuring loggers that targets specific named loggers. It uses a comma-seperated-value (CSV) list of keyvalues.

eg:
--loglevel error,defra.cli=debug
will set the global level for all loggers to error and then the defra.cli level to debug specifically.

It supports an unbounded number of named logger values.

Additionally, introduces a new cli flag --logger which uses the same format, but for all fields of a specific logger, instead of individual fields of many loggers.

eg:
--logger defra.cli,level=debug,output=stdout,format=json
will set the level to debug, output to stdout, and format to json for the logger named defra.cli.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly (REGENERATE CLI DOCS).
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

Some basic integration tests in tests/integration/cli

Specify the platform(s) on which this was tested:

  • Debian Linux WSL2

@codecov
Copy link

codecov bot commented Jul 23, 2022

Codecov Report

Merging #659 (a59c90b) into develop (af5c3cc) will decrease coverage by 4.46%.
The diff coverage is 31.90%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #659      +/-   ##
===========================================
- Coverage    61.68%   57.21%   -4.47%     
===========================================
  Files          123      143      +20     
  Lines        14925    16383    +1458     
===========================================
+ Hits          9206     9374     +168     
- Misses        4859     6127    +1268     
- Partials       860      882      +22     
Impacted Files Coverage Δ
cli/start.go 14.59% <0.00%> (ø)
cli/cli.go 18.03% <18.60%> (ø)
cli/root.go 47.67% <45.00%> (ø)
config/config.go 67.95% <48.93%> (-4.47%) ⬇️
logging/config.go 77.77% <66.66%> (+2.08%) ⬆️
cli/init.go 37.50% <100.00%> (ø)
cli/schema.go 100.00% <0.00%> (ø)
version/version.go 0.00% <0.00%> (ø)
cli/blocks.go 100.00% <0.00%> (ø)
... and 19 more

@jsimnz jsimnz force-pushed the jsimnz/feat/I413-log-config-overrides branch 3 times, most recently from ceca67d to a945835 Compare July 24, 2022 01:03
@source-devs
Copy link

Benchmark Results

Summary

  • 113 Benchmarks successfully compared.
  • 63 Benchmarks were ✅ Better.
  • 50 Benchmarks were ❌ Worse .
  • 0 Benchmarks were ✨ Unchanged.
✅ See Better Results...
time/opdelta
_Collection_UserSimple_CreateMany_Sync_0_100-4232ms ± 0%231ms ± 0%−0.32%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_10-4261µs ± 0%256µs ± 0%−2.01%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_10-4460µs ± 0%442µs ± 0%−3.93%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_10-4412µs ± 0%403µs ± 0%−2.25%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_100-4459µs ± 0%459µs ± 0%−0.09%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_10-4700µs ± 0%670µs ± 0%−4.29%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_100-4717µs ± 0%658µs ± 0%−8.19%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_10-4429µs ± 0%415µs ± 0%−3.19%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_10-4305µs ± 0%296µs ± 0%−3.20%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_100-4323µs ± 0%296µs ± 0%−8.39%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0128-413.4µs ± 0%12.8µs ± 0%−4.46%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0512-416.0µs ± 0%15.3µs ± 0%−4.41%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:1024-420.3µs ± 0%19.2µs ± 0%−5.25%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0064-4134µs ± 0%125µs ± 0%−6.35%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0128-4135µs ± 0%129µs ± 0%−4.63%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0256-4148µs ± 0%139µs ± 0%−6.44%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0512-4188µs ± 0%156µs ± 0%−17.10%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:1024-4200µs ± 0%191µs ± 0%−4.76%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0064-415.5µs ± 0%14.7µs ± 0%−5.20%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0256-415.8µs ± 0%15.1µs ± 0%−4.49%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0512-418.0µs ± 0%16.8µs ± 0%−6.90%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:1024-421.3µs ± 0%20.2µs ± 0%−4.81%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0064-4134µs ± 0%132µs ± 0%−1.70%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0128-4149µs ± 0%139µs ± 0%−6.72%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0256-4153µs ± 0%144µs ± 0%−5.73%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:1024-4215µs ± 0%200µs ± 0%−7.05%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0064-446.3µs ± 0%45.8µs ± 0%−1.15%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0128-446.0µs ± 0%45.5µs ± 0%−0.95%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0256-448.2µs ± 0%47.1µs ± 0%−2.42%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0512-455.3µs ± 0%54.4µs ± 0%−1.61%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0064-4356µs ± 0%346µs ± 0%−2.82%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0128-4362µs ± 0%346µs ± 0%−4.33%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0512-4417µs ± 0%404µs ± 0%−3.10%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0064-444.7µs ± 0%44.2µs ± 0%−0.94%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0128-445.5µs ± 0%44.1µs ± 0%−3.01%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0256-453.0µs ± 0%46.6µs ± 0%−12.18%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0512-455.6µs ± 0%54.7µs ± 0%−1.68%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:1024-468.3µs ± 0%67.7µs ± 0%−0.84%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0064-4367µs ± 0%354µs ± 0%−3.67%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0128-4370µs ± 0%352µs ± 0%−5.01%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0256-4370µs ± 0%367µs ± 0%−1.03%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0512-4438µs ± 0%398µs ± 0%−8.96%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:1024-4498µs ± 0%488µs ± 0%−1.96%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0256-4126µs ± 0%121µs ± 0%−3.82%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0512-4126µs ± 0%126µs ± 0%−0.21%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0128-4125µs ± 0%117µs ± 0%−6.36%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0256-4118µs ± 0%116µs ± 0%−1.84%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0512-4123µs ± 0%119µs ± 0%−3.75%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0064-41.12ms ± 0%1.12ms ± 0%−0.03%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0128-41.17ms ± 0%1.16ms ± 0%−0.80%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0064-48.54µs ± 0%8.17µs ± 0%−4.35%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0128-49.24µs ± 0%8.59µs ± 0%−6.97%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0256-49.91µs ± 0%9.40µs ± 0%−5.17%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:1024-414.7µs ± 0%14.5µs ± 0%−1.72%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0064-487.5µs ± 0%85.8µs ± 0%−1.85%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0256-4101µs ± 0%94µs ± 0%−7.41%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0512-4115µs ± 0%112µs ± 0%−2.44%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:1024-4156µs ± 0%151µs ± 0%−3.11%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0064-4126µs ± 0%123µs ± 0%−2.10%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0128-4131µs ± 0%122µs ± 0%−6.95%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0256-4124µs ± 0%121µs ± 0%−2.31%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0512-4129µs ± 0%129µs ± 0%−0.22%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0512-41.35ms ± 0%1.25ms ± 0%−7.30%(p=1.000 n=1+1)
 
❌ See Worse Results...
time/opdelta
_Collection_UserSimple_Create_Sync_0_10-410.1ms ± 0%10.2ms ± 0%+0.19%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_100-4100ms ± 0%104ms ± 0%+4.36%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_1000-41.00s ± 0%1.01s ± 0%+1.61%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_100-445.1ms ± 0%46.6ms ± 0%+3.32%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_1000-4433ms ± 0%460ms ± 0%+6.08%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_10000-44.55s ± 0%4.71s ± 0%+3.68%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_10_10-4337µs ± 0%359µs ± 0%+6.45%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_100_100-43.60ms ± 0%3.67ms ± 0%+1.74%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_1000-438.6ms ± 0%40.3ms ± 0%+4.48%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_10-4372µs ± 0%377µs ± 0%+1.53%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_100-43.78ms ± 0%3.90ms ± 0%+3.25%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_10_10-4252µs ± 0%256µs ± 0%+1.69%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_100_100-41.78ms ± 0%1.83ms ± 0%+2.99%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_1000-423.7ms ± 0%23.7ms ± 0%+0.17%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_100-41.86ms ± 0%1.86ms ± 0%+0.29%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_100-41.16ms ± 0%1.23ms ± 0%+5.71%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_1000-49.02ms ± 0%9.37ms ± 0%+3.88%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_100-41.22ms ± 0%1.26ms ± 0%+3.39%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_1000-49.38ms ± 0%9.71ms ± 0%+3.60%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_1000-4445µs ± 0%450µs ± 0%+1.17%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_1000-4655µs ± 0%684µs ± 0%+4.45%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_100-41.22ms ± 0%1.23ms ± 0%+1.58%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_1000-410.1ms ± 0%10.6ms ± 0%+4.72%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_1000-4295µs ± 0%295µs ± 0%+0.10%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0256-414.0µs ± 0%14.1µs ± 0%+0.99%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0128-414.8µs ± 0%14.9µs ± 0%+0.45%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0512-4162µs ± 0%167µs ± 0%+3.11%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:1024-465.8µs ± 0%66.0µs ± 0%+0.34%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0256-4360µs ± 0%361µs ± 0%+0.48%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:1024-4481µs ± 0%503µs ± 0%+4.52%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0064-4116µs ± 0%119µs ± 0%+2.52%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0128-4117µs ± 0%119µs ± 0%+1.30%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:1024-4136µs ± 0%137µs ± 0%+0.36%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0064-41.17ms ± 0%1.19ms ± 0%+2.17%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0128-41.17ms ± 0%1.19ms ± 0%+1.74%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0256-41.16ms ± 0%1.20ms ± 0%+4.12%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0512-41.21ms ± 0%1.28ms ± 0%+5.74%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:1024-41.34ms ± 0%1.44ms ± 0%+8.04%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0064-4114µs ± 0%116µs ± 0%+1.49%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:1024-4132µs ± 0%137µs ± 0%+3.49%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0256-41.11ms ± 0%1.18ms ± 0%+6.33%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0512-41.21ms ± 0%1.22ms ± 0%+0.71%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:1024-41.32ms ± 0%1.32ms ± 0%+0.01%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0512-411.1µs ± 0%12.3µs ± 0%+10.68%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0128-487.8µs ± 0%88.1µs ± 0%+0.37%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:1024-4127µs ± 0%130µs ± 0%+1.81%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0064-41.15ms ± 0%1.20ms ± 0%+3.90%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0128-41.20ms ± 0%1.24ms ± 0%+3.79%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0256-41.23ms ± 0%1.25ms ± 0%+1.46%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:1024-41.23ms ± 0%1.27ms ± 0%+3.13%(p=1.000 n=1+1)
 
✨ See Unchanged Results...
time/opdelta
 
🐋 See Full Results...
develop.txtcurrent.txt
time/opdelta
pkg:collection goos:linux goarch:amd64
_Collection_UserSimple_CreateMany_Sync_0_10-410.9ms ± 0%11.0ms ± 0%+0.90%(p=1.000 n=1+1)
_Collection_UserSimple_CreateMany_Sync_0_100-4232ms ± 0%231ms ± 0%−0.32%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_10-410.1ms ± 0%10.2ms ± 0%+0.19%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_100-4100ms ± 0%104ms ± 0%+4.36%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_1000-41.00s ± 0%1.01s ± 0%+1.61%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_100-445.1ms ± 0%46.6ms ± 0%+3.32%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_1000-4433ms ± 0%460ms ± 0%+6.08%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_10000-44.55s ± 0%4.71s ± 0%+3.68%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_10_10-4337µs ± 0%359µs ± 0%+6.45%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_100_100-43.60ms ± 0%3.67ms ± 0%+1.74%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_1000-438.6ms ± 0%40.3ms ± 0%+4.48%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_10-4372µs ± 0%377µs ± 0%+1.53%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_100-43.78ms ± 0%3.90ms ± 0%+3.25%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_10_10-4252µs ± 0%256µs ± 0%+1.69%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_100_100-41.78ms ± 0%1.83ms ± 0%+2.99%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_1000-423.7ms ± 0%23.7ms ± 0%+0.17%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_10-4261µs ± 0%256µs ± 0%−2.01%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_100-41.86ms ± 0%1.86ms ± 0%+0.29%(p=1.000 n=1+1)
pkg:query/simple goos:linux goarch:amd64
_Query_UserSimple_Query_Sync_10-4375µs ± 0%373µs ± 0%−0.62%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_100-41.16ms ± 0%1.23ms ± 0%+5.71%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_1000-49.02ms ± 0%9.37ms ± 0%+3.88%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_10-4460µs ± 0%442µs ± 0%−3.93%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_100-41.22ms ± 0%1.26ms ± 0%+3.39%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_1000-49.38ms ± 0%9.71ms ± 0%+3.60%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_10-4412µs ± 0%403µs ± 0%−2.25%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_100-4459µs ± 0%459µs ± 0%−0.09%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_1000-4445µs ± 0%450µs ± 0%+1.17%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_10-4700µs ± 0%670µs ± 0%−4.29%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_100-4717µs ± 0%658µs ± 0%−8.19%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_1000-4655µs ± 0%684µs ± 0%+4.45%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_10-4429µs ± 0%415µs ± 0%−3.19%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_100-41.22ms ± 0%1.23ms ± 0%+1.58%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_1000-410.1ms ± 0%10.6ms ± 0%+4.72%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_10-4305µs ± 0%296µs ± 0%−3.20%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_100-4323µs ± 0%296µs ± 0%−8.39%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_1000-4295µs ± 0%295µs ± 0%+0.10%(p=1.000 n=1+1)
pkg:storage goos:linux goarch:amd64
_Storage_Simple_Read_Sync_1_10/ValueSize:0064-412.2µs ± 0%12.5µs ± 0%+1.74%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0128-413.4µs ± 0%12.8µs ± 0%−4.46%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0256-414.0µs ± 0%14.1µs ± 0%+0.99%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0512-416.0µs ± 0%15.3µs ± 0%−4.41%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:1024-420.3µs ± 0%19.2µs ± 0%−5.25%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0064-4134µs ± 0%125µs ± 0%−6.35%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0128-4135µs ± 0%129µs ± 0%−4.63%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0256-4148µs ± 0%139µs ± 0%−6.44%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0512-4188µs ± 0%156µs ± 0%−17.10%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:1024-4200µs ± 0%191µs ± 0%−4.76%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0064-415.5µs ± 0%14.7µs ± 0%−5.20%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0128-414.8µs ± 0%14.9µs ± 0%+0.45%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0256-415.8µs ± 0%15.1µs ± 0%−4.49%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0512-418.0µs ± 0%16.8µs ± 0%−6.90%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:1024-421.3µs ± 0%20.2µs ± 0%−4.81%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0064-4134µs ± 0%132µs ± 0%−1.70%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0128-4149µs ± 0%139µs ± 0%−6.72%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0256-4153µs ± 0%144µs ± 0%−5.73%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0512-4162µs ± 0%167µs ± 0%+3.11%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:1024-4215µs ± 0%200µs ± 0%−7.05%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0064-446.3µs ± 0%45.8µs ± 0%−1.15%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0128-446.0µs ± 0%45.5µs ± 0%−0.95%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0256-448.2µs ± 0%47.1µs ± 0%−2.42%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0512-455.3µs ± 0%54.4µs ± 0%−1.61%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:1024-465.8µs ± 0%66.0µs ± 0%+0.34%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0064-4356µs ± 0%346µs ± 0%−2.82%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0128-4362µs ± 0%346µs ± 0%−4.33%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0256-4360µs ± 0%361µs ± 0%+0.48%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0512-4417µs ± 0%404µs ± 0%−3.10%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:1024-4481µs ± 0%503µs ± 0%+4.52%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0064-444.7µs ± 0%44.2µs ± 0%−0.94%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0128-445.5µs ± 0%44.1µs ± 0%−3.01%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0256-453.0µs ± 0%46.6µs ± 0%−12.18%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0512-455.6µs ± 0%54.7µs ± 0%−1.68%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:1024-468.3µs ± 0%67.7µs ± 0%−0.84%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0064-4367µs ± 0%354µs ± 0%−3.67%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0128-4370µs ± 0%352µs ± 0%−5.01%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0256-4370µs ± 0%367µs ± 0%−1.03%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0512-4438µs ± 0%398µs ± 0%−8.96%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:1024-4498µs ± 0%488µs ± 0%−1.96%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0064-4116µs ± 0%119µs ± 0%+2.52%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0128-4117µs ± 0%119µs ± 0%+1.30%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0256-4126µs ± 0%121µs ± 0%−3.82%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0512-4126µs ± 0%126µs ± 0%−0.21%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:1024-4136µs ± 0%137µs ± 0%+0.36%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0064-41.17ms ± 0%1.19ms ± 0%+2.17%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0128-41.17ms ± 0%1.19ms ± 0%+1.74%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0256-41.16ms ± 0%1.20ms ± 0%+4.12%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0512-41.21ms ± 0%1.28ms ± 0%+5.74%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:1024-41.34ms ± 0%1.44ms ± 0%+8.04%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0064-4114µs ± 0%116µs ± 0%+1.49%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0128-4125µs ± 0%117µs ± 0%−6.36%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0256-4118µs ± 0%116µs ± 0%−1.84%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0512-4123µs ± 0%119µs ± 0%−3.75%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:1024-4132µs ± 0%137µs ± 0%+3.49%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0064-41.12ms ± 0%1.12ms ± 0%−0.03%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0128-41.17ms ± 0%1.16ms ± 0%−0.80%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0256-41.11ms ± 0%1.18ms ± 0%+6.33%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0512-41.21ms ± 0%1.22ms ± 0%+0.71%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:1024-41.32ms ± 0%1.32ms ± 0%+0.01%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0064-48.54µs ± 0%8.17µs ± 0%−4.35%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0128-49.24µs ± 0%8.59µs ± 0%−6.97%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0256-49.91µs ± 0%9.40µs ± 0%−5.17%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0512-411.1µs ± 0%12.3µs ± 0%+10.68%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:1024-414.7µs ± 0%14.5µs ± 0%−1.72%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0064-487.5µs ± 0%85.8µs ± 0%−1.85%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0128-487.8µs ± 0%88.1µs ± 0%+0.37%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0256-4101µs ± 0%94µs ± 0%−7.41%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0512-4115µs ± 0%112µs ± 0%−2.44%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:1024-4156µs ± 0%151µs ± 0%−3.11%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0064-4126µs ± 0%123µs ± 0%−2.10%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0128-4131µs ± 0%122µs ± 0%−6.95%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0256-4124µs ± 0%121µs ± 0%−2.31%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0512-4129µs ± 0%129µs ± 0%−0.22%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:1024-4127µs ± 0%130µs ± 0%+1.81%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0064-41.15ms ± 0%1.20ms ± 0%+3.90%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0128-41.20ms ± 0%1.24ms ± 0%+3.79%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0256-41.23ms ± 0%1.25ms ± 0%+1.46%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0512-41.35ms ± 0%1.25ms ± 0%−7.30%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:1024-41.23ms ± 0%1.27ms ± 0%+3.13%(p=1.000 n=1+1)
 

@jsimnz jsimnz added feature New feature or request action/no-benchmark Skips the action that runs the benchmark. area/cli Related to the CLI binary labels Jul 24, 2022
@jsimnz jsimnz self-assigned this Jul 24, 2022
@jsimnz jsimnz added this to the DefraDB v0.3 milestone Jul 24, 2022
Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good! Just some minor suggestions.

cli/root.go Outdated
@@ -126,3 +136,162 @@ func init() {
log.FatalE(context.Background(), "Could not bind api.address", err)
}
}

// parses and then configures the given config.Config logging subconfig.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick:

Suggested change
// parses and then configures the given config.Config logging subconfig.
// parseAndConfigLog parses and then configures the given config.Config logging subconfig.

cli/root.go Outdated
log.FatalE(ctx, "couldn't parse kv bool", err)
}
logcfg.Color = boolValue
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: should handle the case of invalid field type.

For example I like how this fails:
./build/defradb start --logger "defra.cli,level=debu,output=stdout,format=json"
We get:
2022-07-25T05:58:53.931-0400, FATAL, defra.cli, Could not get logging config, {"Error": "couldn't convert override config: invalid log level: debu"}
Note: level=debu is bad.

OR for ./build/defradb start --logger "defra.cli,level=debug=,output=stdout,format=json"
We get:
2022-07-25T06:02:22.807-0400, FATAL, defra.cli, level was not provided as <key>=<value> pair, {"pair": "level=debug="}
Note: level=debug= is bad.

But for this it doesn't fail and actually starts the server:
./build/defradb start --logger "defra.cli,leva=debug,output=stdout,format=json"
Note: leva is an invalid field type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the first two of your examples, it does get validated later on, so I didn't bother adding validation here, as that would just be doubling up the work, and result in approx the same error message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I should have been clearer. The first 2 I was praising because they get validated (even if it's later). I was suggesting to validate the 3rd (last point) as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, sounds good, will do!

cli/root.go Outdated

type logParamSetterStringFn func(*config.LoggingConfig, string)

// type logParamSetterBoolFn func(*config.LoggingConfig, bool)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Removal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

part of the LEAVE NOW comment, changed to make more clear

log3 = logging.MustNewLogger(testLogger3)
)

// todo - add test asserting that logger logs to file by default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: finishing this todo part of this PR? if not suggest linking to an issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated, removed


// todo - add test asserting that logger logs to file by default

func TestCLILogsToStderrGivenNamedLogLevel(t *testing.T) {
Copy link
Member

@shahzadlone shahzadlone Jul 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Maybe an overkill, but can quickly add tests for some error cases (invalid use, to see exit / fatels are called properly).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be part of the larger CLI tests to be added in 0.4. This is just ensuring that given the log calls, the correct output is produced based on the logger config, of which, one of them is an Error call already.

cfg.Logging.Level = "debug"
cfg.Logging.Format = "json"
cfg.Logging.Stacktrace = true
cfg.Logging.OutputPath = "stdout"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Maybe add this stdout file to the .gitignore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or have it in a temp. directory.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't create a file. When zap sees this it just know the output goes to stdout

Copy link
Member

@shahzadlone shahzadlone Jul 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case Idk why in my local directory a file called stdout was created.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odd, ill check, but yea it shouldn't :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has empty contents.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know why. Will create a PR to fix in a few minutes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

joke: I hope your PR removes the only reference to 666 in our code base :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm #666 fixes it this.

@orpheuslummis
Copy link
Contributor

question: Why prefer logging over log in the config and config file?
With the current implementation, the naming additionally determines which environment variable is considered, ie DEFRA_LOGGING_LEVEL vs DEFRA_LOG_LEVEL.

@jsimnz
Copy link
Member Author

jsimnz commented Jul 25, 2022

question: Why prefer logging over log in the config and config file?
With the current implementation, the naming additionally determines which environment variable is considered, ie DEFRA_LOGGING_LEVEL vs DEFRA_LOG_LEVEL.

When I picked up the branch from Andy, he had changed it. I wasn't 100% aware why so I just sent with it, can change it tho

@orpheuslummis
Copy link
Contributor

question: Why prefer logging over log in the config and config file?
With the current implementation, the naming additionally determines which environment variable is considered, ie DEFRA_LOGGING_LEVEL vs DEFRA_LOG_LEVEL.

When I picked up the branch from Andy, he had changed it. I wasn't 100% aware why so I just sent with it, can change it tho

I see. For now unless there is argument or preference, I suggest we keep it as Log and not Logging.

// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package inline_array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: change pkg name to something meaningful

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, no idea this was here :D (andy code)

setup()
cli.Execute()
predicate()
log1.Flush()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: flush as part of predicate func

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to keep the predicate as simple as possible. The Flush isn't strictly necessary, its just good practise for tests.

cfg.Logging.Level = "debug"
cfg.Logging.Format = "json"
cfg.Logging.Stacktrace = true
cfg.Logging.OutputPath = "stdout"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or have it in a temp. directory.

cli/root.go Outdated
"logoutput", cfg.Log.OutputPath,
"Log output path",
"logger", "",
"named logger parameter override. usage: --logger <name>,level=<level>,output=<output>,etc...",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: IMO is more readable if first word is capitalized

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additional nitpick: I suggest using either ... or etc and not both

cli/root.go Outdated

rootCmd.PersistentFlags().String(
"logoutput", cfg.Logging.OutputPath,
"log output path",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: IMO is more readable if first word of flag description is capitalized

cli/root.go Outdated
// parses and then configures the given config.Config logging subconfig.
// we use log.Fatal instead of returning an error because we can't gurantee
// atomic updates, its either everything is properly set, or we Fatal()
func parseAndConfigLog(ctx context.Context, cfg *config.LoggingConfig, cmd *cobra.Command) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: func to exist in cli.go instead

cli/root.go Outdated
}
}

func parseAndConfigLogAllParams(ctx context.Context, cfg *config.LoggingConfig, kvs string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: func to exist in cli.go instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that its also used in init.go yea it can move.

cli/root.go Outdated
// we use log.Fatal instead of returning an error because we can't gurantee
// atomic updates, its either everything is properly set, or we Fatal()
func parseAndConfigLog(ctx context.Context, cfg *config.LoggingConfig, cmd *cobra.Command) {
// apply logger configuration at the end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: to my eyes, this comment is superfluous

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but also why not just put the deferred code directly at the end instead of using defer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, there was more branching before so defer was used to ensure at various return points things get cleaned up, but the branching has been reduced, so youre absolutely correct.

cli/start.go Outdated
@@ -47,31 +46,9 @@ var startCmd = &cobra.Command{
Short: "Start a DefraDB node",
Long: "Start a new instance of DefraDB node.",
// Load the root config if it exists, otherwise create it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: If PersistentPreRunE goes, its comment should go as well

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new config overide flags :)

There are a few question and suggestions but nothing major. At this point I strongly disagree with the log.Fatal "need" as documented in the parseAndConfigLog function doc. I don't see any reason for not returning an error.

cli/init.go Outdated Show resolved Hide resolved
cli/init.go Outdated Show resolved Hide resolved
cli/root.go Outdated Show resolved Hide resolved
cli/root.go Outdated Show resolved Hide resolved
cli/root.go Outdated Show resolved Hide resolved
logging/config.go Show resolved Hide resolved
tests/integration/cli/log_config_test.go Show resolved Hide resolved
assert.Len(t, logLines, 3)
}

func captureLogLines(t *testing.T, setup func(), predicate func()) []string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: the fact that this works here is beyond me. I tried this in the logging unit test and the pipe wouln't catch anything. This is why I had to create other functions as suggested in the zap community to be able to catch log outputs to stderr.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, well, it does work 😂. Can't speak to the approach you were using before?

@orpheuslummis
Copy link
Contributor

Suggestion: in the cli package, prefer Feedback logging methods to normal logging ones.

@jsimnz
Copy link
Member Author

jsimnz commented Jul 25, 2022

Suggestion: in the cli package, prefer Feedback logging methods to normal logging ones.

Should be done in a seperate PR, as theres more than a few spots on the CLI outside of scope of this PR that would change to Feedback

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the changes specially wrt returning errors :)

@jsimnz jsimnz requested a review from shahzadlone July 25, 2022 23:06
@jsimnz jsimnz force-pushed the jsimnz/feat/I413-log-config-overrides branch from d0c2a98 to f8e4491 Compare July 25, 2022 23:26
}

rootCmd.PersistentFlags().String(
"logger", "",
"Named logger parameter override. usage: --logger <name>,level=<level>,output=<output>,...",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: usage can be capitalized


func parseAndConfigLogAllParams(ctx context.Context, cfg *config.LoggingConfig, kvs string) error {
if kvs == "" {
return nil //nothing todo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: skip the comment or change todo to to do

Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
image

@orpheuslummis
Copy link
Contributor

issue: Previously, the behavior of the start command was to create a defradb rootdir with default config file if no such directory is present. Now, it will create a rootdir without config file which will error with next use of root command.

@orpheuslummis
Copy link
Contributor

issue: Previously, the behavior of the start command was to create a defradb rootdir with default config file if no such directory is present. Now, it will create a rootdir without config file which will error with next use of root command.

I suggest that for this PR, the simplest fix for this is not to remove the implementation of the start command's PersistentPreRunE. A subsequent PR should make the configuration loading behavior cleaner.

@fredcarle
Copy link
Collaborator

issue: Previously, the behavior of the start command was to create a defradb rootdir with default config file if no such directory is present. Now, it will create a rootdir without config file which will error with next use of root command.

Good catch! I had noticed the removal and thought I was going to see it moved somewhere else. Then forgot about it while reviewing.

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing approval until config file creation fix.

@jsimnz
Copy link
Member Author

jsimnz commented Jul 26, 2022

issue: Previously, the behavior of the start command was to create a defradb rootdir with default config file if no such directory is present. Now, it will create a rootdir without config file which will error with next use of root command.

I suggest that for this PR, the simplest fix for this is not to remove the implementation of the start command's PersistentPreRunE. A subsequent PR should make the configuration loading behavior cleaner.

oops, I did meant to handle this correctly when I was considating the PreRun in root. Great catch! CLI integration tests will def be a priority next release!

@jsimnz jsimnz requested a review from fredcarle July 26, 2022 00:20
cli/start.go Outdated

// parse loglevel overrides
// we use `cfg.Logging.Level` as an argument since the viper.Bind already handles
// binding the flags / EnvVars to the struct
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpik: this comment creeped back into your PR 🧟‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats the consequence of copy/pasting xD

cli/start.go Outdated
Comment on lines 61 to 64
err = cfg.Load(rootDir)
if err != nil {
return fmt.Errorf("failed to load config: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick:

		if err := cfg.Load(rootDir); err != nil {
			return fmt.Errorf("failed to load config: %w", err)
		}

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎊

@jsimnz jsimnz force-pushed the jsimnz/feat/I413-log-config-overrides branch from 5ae2080 to a59c90b Compare July 26, 2022 02:03
@jsimnz jsimnz merged commit 4023b8f into develop Jul 26, 2022
@jsimnz jsimnz deleted the jsimnz/feat/I413-log-config-overrides branch July 26, 2022 02:26
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
Supports a new format for configuring loggers that targets specific named loggers. It uses a comma-seperated-value (CSV) list of keyvalues.

eg:
--loglevel error,defra.cli=debug
will set the global level for all loggers to error and then the defra.cli level to debug specifically.

It supports an unbounded number of named logger values.

Additionally, introduces a new cli flag --logger which uses the same format, but for all fields of a specific logger, instead of individual fields of many loggers.

eg:
--logger defra.cli,level=debug,output=stdout,format=json
will set the level to debug, output to stdout, and format to json for the logger named defra.cli.

Co-authored-by: Andrew Sisley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/cli Related to the CLI binary feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support named logger config overrides
6 participants