Skip to content

Commit d3c2767

Browse files
authored
Improve references in the main docstrings (#131)
1 parent d6ca2c4 commit d3c2767

File tree

1 file changed

+40
-27
lines changed

1 file changed

+40
-27
lines changed

logfire/_internal/main.py

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ def trace(
218218
msg_template: The message to log.
219219
attributes: The attributes to bind to the log.
220220
_tags: An optional sequence of tags to include in the log.
221-
_exc_info: Set to an exception or a tuple as returned by `sys.exc_info()`
221+
_exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
222222
to record a traceback with the log message.
223-
Set to True to use the currently handled exception.
223+
224+
Set to `True` to use the currently handled exception.
224225
"""
225226
if any(k.startswith('_') for k in attributes):
226227
raise ValueError('Attribute keys cannot start with an underscore.')
@@ -247,9 +248,10 @@ def debug(
247248
msg_template: The message to log.
248249
attributes: The attributes to bind to the log.
249250
_tags: An optional sequence of tags to include in the log.
250-
_exc_info: Set to an exception or a tuple as returned by `sys.exc_info()`
251+
_exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
251252
to record a traceback with the log message.
252-
Set to True to use the currently handled exception.
253+
254+
Set to `True` to use the currently handled exception.
253255
"""
254256
if any(k.startswith('_') for k in attributes):
255257
raise ValueError('Attribute keys cannot start with an underscore.')
@@ -276,9 +278,10 @@ def info(
276278
msg_template: The message to log.
277279
attributes: The attributes to bind to the log.
278280
_tags: An optional sequence of tags to include in the log.
279-
_exc_info: Set to an exception or a tuple as returned by `sys.exc_info()`
281+
_exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
280282
to record a traceback with the log message.
281-
Set to True to use the currently handled exception.
283+
284+
Set to `True` to use the currently handled exception.
282285
"""
283286
if any(k.startswith('_') for k in attributes):
284287
raise ValueError('Attribute keys cannot start with an underscore.')
@@ -305,9 +308,10 @@ def notice(
305308
msg_template: The message to log.
306309
attributes: The attributes to bind to the log.
307310
_tags: An optional sequence of tags to include in the log.
308-
_exc_info: Set to an exception or a tuple as returned by `sys.exc_info()`
311+
_exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
309312
to record a traceback with the log message.
310-
Set to True to use the currently handled exception.
313+
314+
Set to `True` to use the currently handled exception.
311315
"""
312316
if any(k.startswith('_') for k in attributes):
313317
raise ValueError('Attribute keys cannot start with an underscore.')
@@ -334,9 +338,10 @@ def warn(
334338
msg_template: The message to log.
335339
attributes: The attributes to bind to the log.
336340
_tags: An optional sequence of tags to include in the log.
337-
_exc_info: Set to an exception or a tuple as returned by `sys.exc_info()`
341+
_exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
338342
to record a traceback with the log message.
339-
Set to True to use the currently handled exception.
343+
344+
Set to `True` to use the currently handled exception.
340345
"""
341346
if any(k.startswith('_') for k in attributes):
342347
raise ValueError('Attribute keys cannot start with an underscore.')
@@ -363,9 +368,10 @@ def error(
363368
msg_template: The message to log.
364369
attributes: The attributes to bind to the log.
365370
_tags: An optional sequence of tags to include in the log.
366-
_exc_info: Set to an exception or a tuple as returned by `sys.exc_info()`
371+
_exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
367372
to record a traceback with the log message.
368-
Set to True to use the currently handled exception.
373+
374+
Set to `True` to use the currently handled exception.
369375
"""
370376
if any(k.startswith('_') for k in attributes):
371377
raise ValueError('Attribute keys cannot start with an underscore.')
@@ -392,9 +398,10 @@ def fatal(
392398
msg_template: The message to log.
393399
attributes: The attributes to bind to the log.
394400
_tags: An optional sequence of tags to include in the log.
395-
_exc_info: Set to an exception or a tuple as returned by `sys.exc_info()`
401+
_exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
396402
to record a traceback with the log message.
397-
Set to True to use the currently handled exception.
403+
404+
Set to `True` to use the currently handled exception.
398405
"""
399406
if any(k.startswith('_') for k in attributes):
400407
raise ValueError('Attribute keys cannot start with an underscore.')
@@ -417,7 +424,7 @@ def exception(
417424
msg_template: The message to log.
418425
attributes: The attributes to bind to the log.
419426
_tags: An optional sequence of tags to include in the log.
420-
_exc_info: Set to an exception or a tuple as returned by `sys.exc_info()`
427+
_exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
421428
to record a traceback with the log message.
422429
"""
423430
if any(k.startswith('_') for k in attributes): # pragma: no cover
@@ -450,7 +457,6 @@ def span(
450457
_tags: An optional sequence of tags to include in the span.
451458
_level: An optional log level name.
452459
_stack_offset: The stack level offset to use when collecting stack info, defaults to `3`.
453-
454460
attributes: The arguments to include in the span and format the message template with.
455461
Attributes starting with an underscore are not allowed.
456462
"""
@@ -519,16 +525,20 @@ def log(
519525
msg_template: The message to log.
520526
attributes: The attributes to bind to the log.
521527
tags: An optional sequence of tags to include in the log.
522-
exc_info: Set to an exception or a tuple as returned by `sys.exc_info()`
528+
exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
523529
to record a traceback with the log message.
524-
Set to True to use the currently handled exception.
530+
531+
Set to `True` to use the currently handled exception.
525532
stack_offset: The stack level offset to use when collecting stack info, also affects the warning which
526533
message formatting might emit, defaults to `0` which means the stack info will be collected from the
527-
position where `logfire.log` was called.
534+
position where [`logfire.log`][logfire.Logfire.log] was called.
528535
console_log: Whether to log to the console, defaults to `True`.
529-
custom_scope_suffix: A custom suffix to append to `logfire.`, should only be used when you're using
530-
logfire to instrument another library like structlog or loguru.
531-
See `TraceProvider.get_tracer(instrumenting_module_name)` docstring for more info.
536+
custom_scope_suffix: A custom suffix to append to `logfire.` e.g. `logfire.loguru`.
537+
538+
It should only be used when instrumenting another library with Logfire, such as structlog or loguru.
539+
540+
See the `instrumenting_module_name` parameter on
541+
[TracerProvider.get_tracer][opentelemetry.sdk.trace.TracerProvider.get_tracer] for more info.
532542
"""
533543
stack_offset = (self._stack_offset if stack_offset is None else stack_offset) + 2
534544
stack_info = get_caller_stack_info(stack_offset)
@@ -639,11 +649,14 @@ def with_settings(
639649
tags: Sequence of tags to include in the log.
640650
stack_offset: The stack level offset to use when collecting stack info, also affects the warning which
641651
message formatting might emit, defaults to `0` which means the stack info will be collected from the
642-
position where `logfire.log` was called.
652+
position where [`logfire.log`][logfire.Logfire.log] was called.
643653
console_log: Whether to log to the console, defaults to `True`.
644-
custom_scope_suffix: A custom suffix to append to `logfire.`, should only be used when you're using
645-
logfire to instrument another library like structlog or loguru.
646-
See `TraceProvider.get_tracer(instrumenting_module_name)` docstring for more info.
654+
custom_scope_suffix: A custom suffix to append to `logfire.` e.g. `logfire.loguru`.
655+
656+
It should only be used when instrumenting another library with Logfire, such as structlog or loguru.
657+
658+
See the `instrumenting_module_name` parameter on
659+
[TracerProvider.get_tracer][opentelemetry.sdk.trace.TracerProvider.get_tracer] for more info.
647660
648661
Returns:
649662
A new Logfire instance with the given settings applied.
@@ -1081,7 +1094,7 @@ def shutdown(self, timeout_millis: int = 30_000, flush: bool = True) -> bool: #
10811094
flush: Whether to flush remaining spans and metrics before shutting down.
10821095
10831096
Returns:
1084-
False if the timeout was reached before the shutdown was completed, True otherwise.
1097+
`False` if the timeout was reached before the shutdown was completed, `True` otherwise.
10851098
"""
10861099
start = time()
10871100
if flush: # pragma: no branch

0 commit comments

Comments
 (0)