mirror of
				https://github.com/InsanusMokrassar/KSLog.git
				synced 2025-10-30 19:10:17 +00:00 
			
		
		
		
	Compare commits
	
		
			8 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9441f77b18 | |||
| de56994cf7 | |||
| c15d7f23e2 | |||
| 63b29d3665 | |||
| 2b79b6d060 | |||
| 82085783c0 | |||
| 5f49b183e0 | |||
| 365acacbd2 | 
							
								
								
									
										2
									
								
								.github/workflows/kdocs.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/kdocs.yml
									
									
									
									
										vendored
									
									
								
							| @@ -17,5 +17,5 @@ jobs: | ||||
|         uses: peaceiris/actions-gh-pages@v3 | ||||
|         with: | ||||
|           github_token: ${{ secrets.GITHUB_TOKEN }} | ||||
|           publish_dir: ./docs/build/dokka/html | ||||
|           publish_dir: ./build/dokka/html | ||||
|           publish_branch: kdocs | ||||
|   | ||||
							
								
								
									
										10
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -1,5 +1,15 @@ | ||||
| # Changelog | ||||
|  | ||||
| ## 0.0.3 | ||||
|  | ||||
| * Fixes in `JVM` logging | ||||
|  | ||||
| ## 0.0.2 | ||||
|  | ||||
| * New logger `TagLogger` and now extension `Any#logger` will use it to decrease objects allocations | ||||
| * Now it is possible to create `KSLog` using any iterable | ||||
| * Now it is possible to create `KSLog` using vararg log levels | ||||
|  | ||||
| ## 0.0.1 | ||||
|  | ||||
| * Project has been inited | ||||
|   | ||||
| @@ -9,5 +9,5 @@ android.enableJetifier=true | ||||
| # Project data | ||||
|  | ||||
| group=dev.inmo | ||||
| version=0.0.1 | ||||
| android_code_version=1 | ||||
| version=0.0.3 | ||||
| android_code_version=3 | ||||
|   | ||||
| @@ -2,7 +2,5 @@ package dev.inmo.kslog.common | ||||
|  | ||||
| val Any.logTag | ||||
|     get() = this::class.simpleName ?: error("Unable to retrieve log tag") | ||||
| val Any.logger | ||||
|     get() = CallbackKSLog { l, t, m, e -> | ||||
|         KSLog.default.performLog(l, t ?: logTag, m, e) | ||||
|     } | ||||
| val Any.logger: KSLog | ||||
|     get() = TagLogger(logTag) | ||||
|   | ||||
| @@ -44,11 +44,21 @@ expect fun KSLog( | ||||
|  | ||||
| fun KSLog( | ||||
|     defaultTag: String, | ||||
|     levels: Set<LogLevel> | ||||
| ): KSLog = KSLog (defaultTag) { l, _, _, _ -> | ||||
|     levels: Iterable<LogLevel> | ||||
| ): KSLog { | ||||
|     val levels = levels.toSet() | ||||
|     return KSLog (defaultTag) { l, _, _, _ -> | ||||
|         l in levels | ||||
|     } | ||||
| } | ||||
|  | ||||
| inline fun KSLog( | ||||
|     defaultTag: String, | ||||
|     firstLevel: LogLevel, | ||||
|     secondLevel: LogLevel, | ||||
|     vararg otherLevels: LogLevel | ||||
| ): KSLog = KSLog(defaultTag, setOf(firstLevel, secondLevel, *otherLevels)) | ||||
|  | ||||
| fun KSLog( | ||||
|     defaultTag: String, | ||||
|     minLoggingLevel: LogLevel = LogLevel.VERBOSE | ||||
|   | ||||
							
								
								
									
										10
									
								
								src/commonMain/kotlin/TagLogger.kt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/commonMain/kotlin/TagLogger.kt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| package dev.inmo.kslog.common | ||||
|  | ||||
| import kotlin.jvm.JvmInline | ||||
|  | ||||
| @JvmInline | ||||
| value class TagLogger(val tag: String) : KSLog { | ||||
|     override fun performLog(level: LogLevel, tag: String?, message: String, throwable: Throwable?) { | ||||
|         KSLog.performLog(level, tag ?: tag, message, throwable) | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user