-
Notifications
You must be signed in to change notification settings - Fork 122
Improve LoggingInterceptor: Android log priority support, batched pretty logs, and JitPack-ready sink #97
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
Draft
rtsketo
wants to merge
19
commits into
ihsanbal:master
Choose a base branch
from
rtsketo:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8b76667
Support Android Log priorities without custom logger
d472314
[ImgBot] Optimize images
ImgBotApp 8455afc
Fix build: plugin order and trailing commas for Kotlin 1.3
0caacdd
Allow overriding group/version via Gradle properties
0837d39
Skip blank log lines to avoid Logcat collapsing
fda6de2
Tighten response formatting: single status line, skip blank lines
032de99
Adjust response spacing: status line only, allow single blank before …
1868b2b
Add sink support with batching for whole-call logs
cbdb679
Add LogSink/BatchingSink types for aggregated output
8458b2f
Document sink/batching usage and JitPack fork
a4d186b
Merge pull request #1 from rtsketo/imgbot
rtsketo 16431bd
Make LogSink public and fix Kotlin 1.3 trailing comma
b40d4e3
Make BatchingSink public for external use
e9fbdc1
Document public BatchingSink and JitPack fork version
b9d6080
Clarify sink usage and Logcat chunking in README
1c0cb86
Always print box borders even with sinks
d3cd513
Fix emit smart-cast for sink/logger
7c517fc
Docs: keep upstream Maven coords; fork version via tag
226e638
Ignore .kotlin artifacts, in gitignore
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,4 +5,5 @@ local.properties | |
| build | ||
| captures | ||
| .externalNativeBuild | ||
| .idea/ | ||
| .idea/ | ||
| .kotlin | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| /build | ||
| .kotlin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.ihsanbal.logging | ||
|
|
||
| import java.util.concurrent.ConcurrentHashMap | ||
|
|
||
| /** | ||
| * Batches all lines for a request/response and flushes them as one block. | ||
| */ | ||
| class BatchingSink( | ||
| private val delegate: LogSink | ||
| ) : LogSink { | ||
|
|
||
| private data class BufferKey(val tag: String) | ||
|
|
||
| private val buffers = ConcurrentHashMap<BufferKey, StringBuilder>() | ||
|
|
||
| override fun log(type: Int, tag: String, message: String) { | ||
| val key = BufferKey(tag) | ||
| val buffer = buffers.getOrPut(key) { StringBuilder() } | ||
| if (buffer.isNotEmpty()) buffer.append('\n') | ||
| buffer.append(message) | ||
| } | ||
|
|
||
| override fun close(type: Int, tag: String) { | ||
| val key = BufferKey(tag) | ||
| buffers.remove(key)?.let { block -> | ||
| delegate.log(type, tag, block.toString()) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.ihsanbal.logging | ||
|
|
||
| interface LogSink { | ||
| fun log(type: Int, tag: String, message: String) | ||
| fun close(type: Int, tag: String) {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extension is expired so need to be replaced with binding