-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
91 lines (77 loc) · 2.42 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import 'package:paw/paw.dart';
///
/// This is an example showcasing how to use the Paw logging library in Flutter.
/// You can run this example by executing `dart example/main.dart` in your terminal.
///
void main() {
///
/// Create an instance of [paw] with custom configurations.
///
final paw = Paw(
// optional, defaults to [PAW]
title: "MyApp",
// optional, defaults to [true]
shouldIncludeSourceFileInfo: true,
// optional, defaults to [true]
shouldIncludeTitle: true,
// optional, defaults to [true]
shouldPrint: true,
// optional, defaults to [5]
stackTraceToPrint: 5,
// optional, defaults to [PawDarkTheme]
theme: PawDarkTheme(),
// Note: When the `level` is set to [null], Paw is allowed to print logs
// of all levels. To only print logs of a certain level, set the `level` to
// that specific level, e.g. [PawLogLevels.fetal] to only print fetal logs
level: null, // this allows paw to print all the logs, defaults to [null]
);
///
/// Log an informational message.
///
/// Use this for general app flow information, which could be helpful for
/// understanding the app's behavior.
///
paw.info("This is an informational message");
///
/// Log a tracing message
///
/// Use this for tracking code flow and high-volume logs
///
paw.trace("This is a trace log");
///
/// Log a warning message.
///
/// Warnings are useful for non-critical issues that should be
/// brought to attention.
///
paw.warn("Be aware! This is a warning message");
///
/// Log a data object for debugging.
///
/// This is particularly useful for logging structured data, making it
/// easier to understand complex data states.
///
paw.debug({'key': 'value', 'count': 42});
///
/// Log an error with additional context.
/// Here you can pass a message, an error object, and even a stack trace
/// for in-depth debugging.
///
/// Use this for logging exceptions or errors that occur in your application.
///
try {
throw UnsupportedError("Oops! You've forgotten to implement this feature");
} catch (e, stackTrace) {
// Log an error with a message and error object
paw.error(
'An unexpected error occurred',
error: e,
);
// Log a fetal log with a message, error object, and stack trace
paw.fetal(
'A very serious error occurred',
stackTrace: stackTrace,
error: e,
);
}
}