astute_logger 0.0.1
astute_logger: ^0.0.1 copied to clipboard
A simple and powerful logger for Flutter apps with support for color-coding, JSON pretty-printing, and performance tracking.
import 'package:astute_logger/astute_logger.dart';
void main() {
final log = Logger("ExampleService");
// ๐ต Basic message
log.write(message: "App started", level: LogLevel.info);
// ๐ข Debug message
log.write(message: "Fetching user...", level: LogLevel.debug);
// ๐ก Warning
log.write(message: "Low internet connection", level: LogLevel.warning);
// ๐ด Error
log.write(message: "Failed to load data", level: LogLevel.error);
// ๐จ Log with color
log.logWithColor("Custom colored success log", color: LogColor.green.code);
// ๐งพ Pretty JSON
log.logJson({
"id": 1,
"name": "John",
"role": "admin",
});
// ๐งพ Pretty JSON string
log.write(
message: '{"status": "ok", "items": [1,2,3]}',
prettyPrint: true,
level: LogLevel.info,
);
// ๐ Pretty List
log.logPrettyList(["Apple", "Banana", "Orange"], label: "Fruits");
// โฑ Execution time measurement
log.logExecutionTime("Compute sum", () {
final list = List.generate(5000, (i) => i);
return list.reduce((a, b) => a + b);
});
}