ansiPrint function
Implementation
String ansiPrint(
msg, {
DateTime? date,
Level level = Level.debug,
String? service,
String? module,
DateFormat? dateFormat,
LoggerOptions options = defaultLevelOptions,
bool shouldPrint = true,
}) {
service ??= Platform.localHostname;
dateFormat ??= defaultDateFormat;
date ??= DateTime.now();
final mService = textToAnsi(service, style: options.service, enableAnsi: options.enableAnsi);
final mModule = module == null ? '' : ':${textToAnsi(module, style: options.module, enableAnsi: options.enableAnsi)}';
final mDate = textToAnsi('[${dateFormat.format(date)}]', style: options.date, enableAnsi: options.enableAnsi);
final levelStyle = level.logStyleFromOptions(options);
final mLevel = textToAnsi(levelStyle.item1, style: levelStyle.item2, enableAnsi: options.enableAnsi);
final log = '$mDate $mLevel $mService$mModule $msg';
if (shouldPrint) print(log);
return log;
// date, level, module, msg
}