Skip to content

Commit e485b11

Browse files
committed
Improve phrasing in docstrings
1 parent 6c1ece2 commit e485b11

File tree

6 files changed

+21
-19
lines changed

6 files changed

+21
-19
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ For more configuration options, see:
203203

204204
### Performance
205205

206-
- All the methods on `Logger` take a lambda argument to build the log, which is only called if the
207-
log level is enabled - so you only pay for message string concatenation and log field
208-
serialization if it's actually logged.
206+
- All the methods on `Logger` take a lambda to build the log, which is only called if the log level
207+
is enabled - so you only pay for message string concatenation and log field serialization if it's
208+
actually logged.
209209
- `Logger`'s methods are also `inline`, so we avoid the cost of allocating a function object for the
210-
lambda argument.
210+
lambda parameter.
211211
- Elsewhere in the library, we use inline value classes when wrapping SLF4J/Logback APIs, to get as
212212
close as possible to a zero-cost abstraction.
213213

src/commonMain/kotlin/dev/hermannm/devlog/ExceptionWithLogFields.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ package dev.hermannm.devlog
6868
* exception
6969
* - `(message: String?, vararg logFields: LogField, cause: Throwable?)`
7070
* - Takes log fields as varargs, so you don't have to wrap them in a list
71-
* - To pass `cause`, use a named parameter
71+
* - To pass `cause`, use a named argument
7272
* - `(logFields: List<LogField>, cause: Throwable?)`
7373
* - Defaults `message` to `cause.message`. This lets you:
7474
* - Wrap a cause exception with log fields, and use the cause exception's message

src/commonMain/kotlin/dev/hermannm/devlog/LogBuilder.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import kotlinx.serialization.SerializationStrategy
99
* Class used in the logging methods on [Logger], allowing you to add structured key-value data to
1010
* the log by calling the [field] and [rawJsonField] methods.
1111
*
12-
* This class is given as a receiver to the lambda arguments on `Logger`'s methods, which lets you
13-
* call its methods directly in the scope of that lambda. This is a common technique for creating
14-
* _type-safe builders_ in Kotlin (see the
12+
* This class is provided as a receiver for the `buildLog` lambda parameter on `Logger`'s methods,
13+
* which lets you call its methods directly in the scope of the lambda. This is a common pattern for
14+
* creating _type-safe builders_ in Kotlin (see the
1515
* [Kotlin docs](https://kotlinlang.org/docs/lambdas.html#function-literals-with-receiver) for more
1616
* on this).
1717
*
@@ -49,7 +49,7 @@ internal constructor(
4949
*
5050
* If you want to specify the serializer for the value explicitly, you can call the overload of
5151
* this method that takes a [SerializationStrategy][kotlinx.serialization.SerializationStrategy]
52-
* as a third argument. That is also useful for cases where you can't call this method with a
52+
* as a third parameter. That is also useful for cases where you can't call this method with a
5353
* reified type parameter.
5454
*
5555
* If you have a value that is already serialized, you should use [rawJsonField] instead.
@@ -125,7 +125,7 @@ internal constructor(
125125
*
126126
* If you want to specify the serializer for the value explicitly, you can call the overload of
127127
* this method that takes a [SerializationStrategy][kotlinx.serialization.SerializationStrategy]
128-
* as a third argument. That is also useful for cases where you can't call this method with a
128+
* as a third parameter. That is also useful for cases where you can't call this method with a
129129
* reified type parameter.
130130
*
131131
* If you have a value that is already serialized, you should use [rawJsonField] instead.

src/commonMain/kotlin/dev/hermannm/devlog/LogField.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ internal open class JsonLogField(
156156
*
157157
* If you want to specify the serializer for the value explicitly, you can call the overload of this
158158
* function that takes a [SerializationStrategy][kotlinx.serialization.SerializationStrategy] as a
159-
* third argument. That is also useful for cases where you can't call this function with a reified
159+
* third parameter. That is also useful for cases where you can't call this function with a reified
160160
* type parameter.
161161
*
162162
* If you have a value that is already serialized, you should use [rawJsonField] instead.
@@ -192,7 +192,7 @@ public inline fun <reified ValueT> field(key: String, value: ValueT): LogField {
192192
*
193193
* If you want to specify the serializer for the value explicitly, you can call the overload of this
194194
* function that takes a [SerializationStrategy][kotlinx.serialization.SerializationStrategy] as a
195-
* third argument. That is also useful for cases where you can't call this function with a reified
195+
* third parameter. That is also useful for cases where you can't call this function with a reified
196196
* type parameter.
197197
*
198198
* If you have a value that is already serialized, you should use [rawJsonField] instead.

src/commonMain/kotlin/dev/hermannm/devlog/LogLevel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ public class LogLevel private constructor() {
9999
* will always be unreachable as long as we check all the levels defined on the companion object
100100
* here - since the constructor is private, there will be no other instances. To keep this logic
101101
* in one place, we provide this method to emulate a `when` expression on a log level:
102-
* - We take a lambda argument for each log level, to ensure that all cases are covered
102+
* - We take a lambda parameter for each log level, to ensure that all cases are covered
103103
* - We make the method `inline`, so we don't pay a cost for the lambdas
104104
* - In the unreachable else branch, we throw an exception
105105
*
106106
* We may be able to use an enum/sealed class instead if
107107
* [this issue moves along](https://youtrack.jetbrains.com/issue/KT-38750/Support-declaration-site-nonexhaustiveness-for-enums-and-sealed-classes).
108108
*/
109-
@Suppress("LocalVariableName") // We want the argument names here to be the same as the constants
109+
@Suppress("LocalVariableName") // We want the parameter names here to be the same as the constants
110110
internal inline fun <ReturnT> match(
111111
crossinline ERROR: () -> ReturnT,
112112
crossinline WARN: () -> ReturnT,

src/commonMain/kotlin/dev/hermannm/devlog/Logger.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import kotlin.reflect.KClass
1212
* enable/disable log levels for loggers based on their package names, or query for logs from a
1313
* specific class.
1414
*
15-
* The easiest way to construct a logger is by calling [getLogger] with an empty lambda argument.
16-
* This automatically gives the logger the name of its containing class (or file, if defined at the
17-
* top level).
15+
* The easiest way to construct a logger is by calling [getLogger] with zero arguments. This
16+
* automatically gives the logger the name of its containing class (or file, if defined at the top
17+
* level). See the "Implementation" section on [getLogger]'s docstring for how this works.
1818
*
1919
* ```
2020
* // In file Example.kt
@@ -494,7 +494,7 @@ public expect inline fun getLogger(): Logger
494494
* The logger name is included in the log output, and can be used to enable/disable log levels for
495495
* loggers based on their package names, or query for logs from a specific class.
496496
*
497-
* In most cases, you should prefer the zero-argument `getLogger()` overload, to automatically get
497+
* In most cases, you should prefer the zero-parameter `getLogger()` overload, to automatically get
498498
* the name of the containing class (or file). But if you want more control over which class to use
499499
* for the logger name, you can use this overload.
500500
*
@@ -526,14 +526,16 @@ public expect fun getLogger(forClass: KClass<*>): Logger
526526
* loggers based on their package names, or query for logs from a specific class. Because of this,
527527
* the name given here should follow fully qualified class name format, like `com.example.Example`.
528528
*
529-
* To set the name automatically from the containing class/file, you can use the zero-argument
529+
* To set the name automatically from the containing class/file, you can use the zero-parameter
530530
* `getLogger()` overload instead.
531531
*
532532
* ### Example
533533
*
534534
* ```
535535
* private val log = getLogger(name = "com.example.Example")
536536
* ```
537+
*
538+
* @param name Should follow fully qualified class name format, like `com.example.Example`.
537539
*/
538540
public expect fun getLogger(name: String): Logger
539541

0 commit comments

Comments
 (0)