logg function
void
logg(})
Prints a log message with optional color, length limit, and name.
The value is the message to be logged.
The color parameter sets the color of the log message (default: yellow).
The limit parameter specifies the maximum length of the log message (default: 500).
The name parameter is an optional name to be displayed along with the log message.
The nolimit parameter, if set to true, disables the length limit of the log message.
Example usage:
logg('lorem ipsum', color: LogColor.red, limit: 3000);
Implementation
void logg(dynamic value,
{LogColor color = LogColor.yellow,
int limit = 500,
String? name,
bool nolimit = false}) {
// Get the string representation of the value
String valueString = '$value';
// Get a substring of the value based on the limit
String subStr = '$value'.substring(
0,
nolimit
? 999999
: valueString.length > limit
? limit
: valueString.length);
// Colorize the substring
String message = colorize(subStr, color);
// Add ellipsis if the substring is shorter than the original value
String logMessage =
subStr.length < valueString.length ? '$message.....' : message;
// Print the log message on the debug console
log(logMessage, name: name ?? 'LOG');
}