Logging
You can log errors, info, debug messages using AppLogger
. By default console logs will be turned off for relase builds.
How To Use
AppLogger.i("Info message")
AppLogger.e("Error message", throwable)
AppLogger.d("Debug message")
Optional Telegram Logger.
Although Firebase Crashlytics was already integrated, solo developers sometimes forget to check it regularly. With optional Telegram Bot logging, you’ll be instantly notified when an error occurs, to fix issues quickly.
How to enable it:
Make sure you update your telegram bot token and chat id in TelegramLogger
file in TELEGRAM_BOT_TOKEN
and TELEGRAM_CHAT_ID
fields. By default they are empty, if they have empty values, then TelegramLogger will not be used. How to get these values:
To get your Telegram Bot Token:
- Open Telegram app and search for the user "@BotFather".
- Start a chat and send the command /newbot.
- Follow the instructions to name your bot and get a unique bot username.
- BotFather will provide you with the Bot Token (a long string) after creation.
To get your Telegram Chat ID:
- Add your bot to a Telegram group or chat where you want to receive messages.
- Alternatively, start a direct chat with your bot.
- To find the chat ID, send a message to the bot or group.
- Use the Telegram API or a tool like
https://api.telegram.org/bot<YourBotToken>/getUpdates
to fetch updates and find the"chat":{"id": ... }
value corresponding to your chat.
Save your Bot Token and Chat ID in TelegramLogger
file in TELEGRAM_BOT_TOKEN
and TELEGRAM_CHAT_ID
fields to enable sending messages.
Now iff you log with error or info message, it will be sent to telegram bot that you created.
AppLogger.i("Some info message")
. You will get info in your telegram bot.