-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Add name filter for log #280
Comments
Hello @a1573595 ! 👋 You can provide any log titles or log types in TalkerFilter constructor and then talker will not show and store relevant logs. final filter = BaseTalkerFilter(
titles: ['Error'],
types: [Exception],
);
final talker = Talker(filter: filter);
talker.info('Any info message'); // Do nothing Does this solve your problem? |
Is the filter title for the log level rather than the type of event? For example, I only want to track Bluetooth, which may contain multiple levels, such as info, warning, and error. |
Yes, filter currently work with types and titles of logs. In this case you need to create custom log class |
@a1573595 you can use example code below: class BluetoothLog extends TalkerLog {
BluetoothLog(String message) : super(message);
/// Your custom log title
@override
String get title => 'bluetooth';
/// Your custom log color
@override
AnsiPen get pen => AnsiPen()..green();
}
void main() {
final talker = Talker(
filter: BaseTalkerFilter(
types: [BluetoothLog], //or titles:['bluetooth']
),
);
talker.logCustom(BluetoothLog('Connected to device id: {deviceId}'));
talker.info('Other logs');
} |
Is your feature request related to a problem? Please describe.
When there are various events in the log, it is not easy to check, refer to Proposal #279, add a filter with custom name to make customized Logger flexible.
Describe the solution you'd like
Add a filter to specify the name of the log to be output.
Describe alternatives you've considered
As an alternative, I could manually add the filter for name or tag in the log message, but this becomes cumbersome and doesn't provide the same level of integration or convenience that a dedicated name parameter would offer.
Adding the ability to specify custom tag filters will allow for better log management, especially in large applications.
The text was updated successfully, but these errors were encountered: