Persist icon indicating copy to clipboard operation
Persist copied to clipboard

Add OSLog support without poisoning namespace

Open JosephDuffy opened this issue 4 years ago • 4 comments

This is an attempt to add support for OSLog without increasing the minimum platform requirements.

The use of a separate target means that the extra types required should not interfere with consumers.

The main question is whether #if canImport(os) will resolve to false on linux. If not then it may fail to compile and a platform check could be required.

JosephDuffy avatar Aug 30 '20 15:08 JosephDuffy

Codecov Report

Merging #22 into master will decrease coverage by 1.74%. The diff coverage is 17.85%.

Impacted file tree graph

@@             Coverage Diff             @@
##            master      #22      +/-   ##
===========================================
- Coverage   100.00%   98.25%   -1.75%     
===========================================
  Files           25       27       +2     
  Lines         1288     1316      +28     
===========================================
+ Hits          1288     1293       +5     
- Misses           0       23      +23     
Impacted Files Coverage Δ
Sources/Persist/Persister.swift 100.00% <ø> (ø)
Sources/PersistLogger/OSLogPersistLogger.swift 8.00% <8.00%> (ø)
Sources/Persist/Persister+OSLog.swift 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 65ea4c8...8d9b3ad. Read the comment docs.

codecov[bot] avatar Aug 30 '20 15:08 codecov[bot]

Interesting that you decided to 'wrap' OSLog considering it's recommended to avoid. I'm keen to hear thoughts on this?

The reason I've seen is usually to not use StaticString, losing the redacted/public options, but that is accounted for here.

I've been using this wrapped in all my projects and haven't had any issues, but maybe there's something I'm unaware of that's being lost?

JosephDuffy avatar Dec 17 '20 14:12 JosephDuffy

Interesting that you decided to 'wrap' OSLog considering it's recommended to avoid. I'm keen to hear thoughts on this?

The reason I've seen is usually to not use StaticString, losing the redacted/public options, but that is accounted for here.

I've been using this wrapped in all my projects and haven't had any issues, but maybe there's something I'm unaware of that's being lost?

No you're right, its when people drop StaticString and do their own interpolation, which obviously is a mistake. I just wondered what the value of doing this is?

shaps80 avatar Dec 17 '20 17:12 shaps80

I've been using this wrapped in all my projects and haven't had any issues, but maybe there's something I'm unaware of that's being lost?

No you're right, its when people drop StaticString and do their own interpolation, which obviously is a mistake. I just wondered what the value of doing this is?

Just personal preference I guess, I find the API easier. Whenever I want to use os_log I never remember which one I want from the list:

image

I have a small Swift Package I use in my projects to keep this code in sync (Beaver) and find it helps me reduce the friction of adding logs.

JosephDuffy avatar Dec 17 '20 20:12 JosephDuffy