You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Designed to enable the user to debug their code and api requests as easily as possible. The package is made so that it is completely safe to use in any environment.( All features will work
only if kDebugMode == true )
Features
Log api client requests and responses.
Log colorized messages to the console.
Log messages to the console with different log levels.
Log FlutterError to the console with level and stack trace.
Configuration
You can configure many things with this package. Please check the example below for more details.
Configuration setup
TsLogger.instance.configure((
messageLoggerConfig,
apiLoggerConfig,
) {
// MessageLoggerConfig
messageLoggerConfig.example ='example';
// ApiLoggerConfig
apiLoggerConfig.example ='example';
// Please check the properties mentioned below for more details.
});
MessageLoggerConfig properties
Property
Description
Default
logLevels
Only the levels you specify using this property will be displayed in the debug console. Useful in the case when, for example, you are only interested in fatal errors, etc.
LogLevel.values (All)
messageSpacing
The spacing around the message in the console.
0
colorizeLogs
If true, the messages will be colorized; otherwise, the text will be white.
true
logMessageTime
If true, the time when the message was logged will be displayed.
true
ApiLoggerConfig properties
Property
Description
Default
_maxResponseBodyLengthForPrint
The maximum length of the body that will be printed to the console.
1500
messageSpacing
The spacing around the message in the console.
2
logRequestQueryParams
If true, the query parameters will be displayed in the console.
true
logRequestHeaders
If true, the request headers will be displayed in the console.
false
ignoreRequestHeaders
The headers which will be ignored in the console. It does not matter whether letters are uppercase or lowercase.
['Authorization']
logRequestBody
If true, the request body will be displayed in the console; otherwise, it will not.
true
successStatusCodes
The status codes that will be considered as successful.
[200, 201]
reportInterval
Represents the interval for reporting the number of successful and failed requests. null means disable.
Duration(minutes: 10)
Usage | Api logging
Api request and response logging
Log API client requests and responses. This is a basic example of usage.
import'package:get/get.dart'as g;
import'package:dio/dio.dart'as d;
final getConnectClient = g.GetConnect();
TsLogger.instance.activateGetConnectLogger(getConnectClient.httpClient);
getConnectClient.get('https://jsonplaceholder.typicode.com/users');
final dioClient = d.Dio();
TsLogger.instance.activateDioLogger(dioClient);
dioClient.get('https://jsonplaceholder.typicode.com/users');
Usage | Message logging
Log messages
Log messages to the console with different log levels. Every log will be unique displayed based on the log level.
TsLogger.instance.logColorizedMessage(...); // Log message with any colorTsLogger.instance.logMessage(...); // Log message for provided log levelTsLogger.instance.logDebug(...); // Log message with debug log levelTsLogger.instance.logInfo(...); // Log message with info log levelTsLogger.instance.logWarning(...); // Log message with warning log levelTsLogger.instance.logError(...); // Log message with error log levelTsLogger.instance.logFatal(...); // Log message with fatal log levelTsLogger.instance.logVerbose(...); // Log message with verbose log levelTsLogger.instance.logCritical(...); // Log message with critical log level
FlutterError logging
Log FlutterError to the console with level and stack trace.