log method
Log error, warning, info, debug, trace, and fatal messages.
You can provide messages for different log levels, and only messages with non-null values will be logged.
e
is for error messages.
w
is for warning messages.
i
is for info messages.
d
is for debug messages.
t
is for trace messages.
f
is for fatal messages.
Implementation
@override
void log({String? e, String? w, String? i, String? d, String? t, String? f}) {
DateTime now = DateTime.now();
final String formattedDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(now);
if ((e != null ? 1 : 0) +
(w != null ? 1 : 0) +
(i != null ? 1 : 0) +
(d != null ? 1 : 0) +
(t != null ? 1 : 0) +
(f != null ? 1 : 0) !=
1) {
_printTextWithIcon(
CustomErrorConstants.LOGGING_ERROR,
TextColor.red,
BackgroundColor.transparent,
Icon.unicodeError,
TextStyle.blink,
paddingLeft: 2, // Left padding
paddingTop: 10, // Top padding
paddingRight: 2, // Right padding
paddingBottom: 10, // Bottom padding
);
}
if (e != null) {
_printTextWithIcon(
'$formattedDate ${CustomErrorConstants.CUSTOM_ERROR}: [Error] $e',
TextColor.red,
BackgroundColor.transparent,
Icon.unicodeError,
TextStyle.blink,
paddingLeft: 2, // Left padding
paddingTop: 10, // Top padding
paddingRight: 2, // Right padding
paddingBottom: 10, // Bottom padding
);
}
if (w != null) {
_printTextWithIcon(
'$formattedDate ${CustomErrorConstants.CUSTOM_ERROR}: [Warning] $w',
TextColor.yellow,
BackgroundColor.transparent,
Icon.unicodeWarning,
TextStyle.blink,
paddingLeft: 2, // Left padding
paddingTop: 10, // Top padding
paddingRight: 2, // Right padding
paddingBottom: 10, // Bottom padding
);
}
if (i != null) {
_printTextWithIcon(
'$formattedDate ${CustomErrorConstants.CUSTOM_ERROR}: [Info] $i',
TextColor.blue,
BackgroundColor.transparent,
Icon.unicodeInfo,
TextStyle.blink,
paddingLeft: 2, // Left padding
paddingTop: 10, // Top padding
paddingRight: 2, // Right padding
paddingBottom: 10, // Bottom padding
);
}
if (d != null) {
_printTextWithIcon(
'$formattedDate ${CustomErrorConstants.CUSTOM_ERROR}: [Debug] $d',
TextColor.blue,
BackgroundColor.transparent,
Icon.unicodeDebug,
TextStyle.blink,
paddingLeft: 2, // Left padding
paddingTop: 10, // Top padding
paddingRight: 2, // Right padding
paddingBottom: 10, // Bottom padding
);
}
if (t != null) {
_printTextWithIcon(
'$formattedDate ${CustomErrorConstants.CUSTOM_ERROR}: [Trace] $t',
TextColor.cyan,
BackgroundColor.transparent,
Icon.unicodeTrace,
TextStyle.blink,
paddingLeft: 2, // Left padding
paddingTop: 10, // Top padding
paddingRight: 2, // Right padding
paddingBottom: 10, // Bottom padding
);
}
if (f != null) {
_printTextWithIcon(
'$formattedDate ${CustomErrorConstants.CUSTOM_ERROR}: [Fatal] $f',
TextColor.red,
BackgroundColor.transparent,
Icon.unicodeFatal,
TextStyle.blink,
paddingLeft: 2, // Left padding
paddingTop: 10, // Top padding
paddingRight: 2, // Right padding
paddingBottom: 10, // Bottom padding
);
}
}