Log class
An annotation that gives a class a ready-made log getter, so its
methods can log without declaring a logger.
The generator writes an extension with a constant SpringLog named
after the class (<package>.<Class>, like
spring_boot_dart.SpringApplication), so levels can be set per class
or per package in configuration. It is the usual way an application
logs.
import 'package:my_app/main.spring.dart'; // the generated file
@Component()
@Log()
class Checkout {
void pay(Order order) => log.info('paid ${order.id}'); // my_app.Checkout
}
@Log(topic: 'neon.payments', fieldName: 'logger')
class Payments {
void refund() => logger.warning('refund');
}
The getter lives in the .spring.dart file of the @ComponentScan or
@SpringBootApplication that scans the class: import that file in the
class's library. A log declared in the library's scope wins over the
getter, and dart:math and dart:developer both declare a function
log, so with one of them imported pick another fieldName. Any
class of the scan may carry it, bean or not.
Spring (Java), with Lombok:
@Slf4j(topic = "neon.payments")
class Payments { void refund() { log.warn("refund"); } }
Constructors
Properties
- fieldName → String
-
The name of the generated getter;
logunless given.final - hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- topic → String?
-
The logger name, to group classes under one name such as
neon.payments;<package>.<Class>whennull.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited