Skip to content

feat: per account imap and smtp debugging#10301

Merged
st3iny merged 1 commit intomainfrom
enh/add-occ-debug-command
Apr 17, 2025
Merged

feat: per account imap and smtp debugging#10301
st3iny merged 1 commit intomainfrom
enh/add-occ-debug-command

Conversation

@SebastianKrupinski
Copy link
Contributor

@SebastianKrupinski SebastianKrupinski commented Oct 28, 2024

At the moment there is no ability to debug a single mail account.

This adds the ability to enable debugging from the command line using a occ command on a single account and protocol. This also creates a separate file for each account that is enable instead of logging all accounts to the same log file. ( {data directory}/mail-{user id}-{account id}-imap.log )

// command arguments and options
mail:account:debug [--on] [--off]

// enable debugging for imap
mail:account:debug 14 --on

// disable debugging
mail:account:debug 14 --off
mail:account:debug 14

// enable for single run with environmental variable
NC_MAIL_DEBUG=true php occ mail:account:sync 14

@SebastianKrupinski SebastianKrupinski self-assigned this Oct 28, 2024
@SebastianKrupinski SebastianKrupinski force-pushed the enh/add-occ-debug-command branch 2 times, most recently from 0e8d1a5 to 22ba6c1 Compare October 28, 2024 23:49
@SebastianKrupinski SebastianKrupinski marked this pull request as draft October 28, 2024 23:58
@SebastianKrupinski
Copy link
Contributor Author

TODO: Fix integration test

@SebastianKrupinski SebastianKrupinski marked this pull request as ready for review October 29, 2024 00:32
@SebastianKrupinski
Copy link
Contributor Author

TODO: Fix integration test

Done

@SebastianKrupinski SebastianKrupinski force-pushed the enh/add-occ-debug-command branch from 77998a6 to 421a8dc Compare October 29, 2024 14:40
Copy link
Member

@st3iny st3iny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment above.

Copy link
Member

@st3iny st3iny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I posted a reply in the thread above.

I meant both. I don't like having a compressed int as a field. That makes it hard to understand when encountered outside of the code, e.g. in a database dump.

As this is not performance critical code I would prefer another way, e.g. a serialized JSON string or concatenated string ("imap|smtp") or similar.

@kesselb
Copy link
Contributor

kesselb commented Nov 5, 2024

Please change "4.1.0-alpha.2" to "4.1.0-alpha.3" in info.xml to trigger the migration.

@kesselb
Copy link
Contributor

kesselb commented Nov 5, 2024

Please change "4.1.0-alpha.2" to "4.1.0-alpha.3" in info.xml to trigger the migration.

You may want to wait until #10326 is merged and bump after a rebase.

@SebastianKrupinski
Copy link
Contributor Author

Please change "4.1.0-alpha.2" to "4.1.0-alpha.3" in info.xml to trigger the migration.

You may want to wait until #10326 is merged and bump after a rebase.

Done. I've changed the version to '4.2.0-alpha.1' that way it will migrate properly after the '4.2.0-alpha.0' release.

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'm missing now is a way to enable Mail debug mode for one occ run.

Before I could do php NC_debug=1 occ mail:account:sync .... This allowed running one sync in debug mode and leave the rest (of production) untouched. Now I have to globally set the account for debug and it will influence production, e.g. through background jobs or when the user has the app open in the browser.

Any idea how we can bring the old trick back?

@SebastianKrupinski
Copy link
Contributor Author

What I'm missing now is a way to enable Mail debug mode for one occ run.

Before I could do php NC_debug=1 occ mail:account:sync .... This allowed running one sync in debug mode and leave the rest (of production) untouched. Now I have to globally set the account for debug and it will influence production, e.g. through background jobs or when the user has the app open in the browser.

Any idea how we can bring the old trick back?

So you want to use a single use environmental variable to enable debugging, no problem.

NC_MAIL_DEBUG=imap php occ mail:account:sync 14

@kesselb
Copy link
Contributor

kesselb commented Nov 7, 2024

I’d like to suggest removing the option to enable debugging separately for each protocol (like IMAP or SMTP). This would make the setup simpler, with just one debug option instead. I think enabling debugging for individual protocols adds extra complexity without much benefit.

@SebastianKrupinski
Copy link
Contributor Author

I’d like to suggest removing the option to enable debugging separately for each protocol (like IMAP or SMTP). This would make the setup simpler, with just one debug option instead. I think enabling debugging for individual protocols adds extra complexity without much benefit.

Well the logic is that you only diagnose issues in one protocol at a time anyway, so there was no point in logging protocols you are not interested in. Lets see what @ChristophWurst and @st3iny think.

@ChristophWurst
Copy link
Member

Let's simplify and get this in

  1. Only one debug mode for both IMAP and SMTP and no "full" mode, it's rarely needed (feat: per account imap and smtp debugging #10301 (comment))
  2. Revive an option to trigger debug mode from an env var, maybe NC_MAIL_DEBUG=true

@SebastianKrupinski SebastianKrupinski force-pushed the enh/add-occ-debug-command branch from 565737f to 47e66ec Compare April 5, 2025 19:23
@SebastianKrupinski
Copy link
Contributor Author

SebastianKrupinski commented Apr 5, 2025

Let's simplify and get this in

1. Only one debug mode for both IMAP and SMTP and no "full" mode, it's rarely needed ([feat: per account imap and smtp debugging #10301 (comment)](https://github.com/nextcloud/mail/pull/10301#issuecomment-2463033797))

2. Revive an option to trigger debug mode from an env var, maybe NC_MAIL_DEBUG=true

Done. Rebased also since this was 5 months old now

@SebastianKrupinski SebastianKrupinski force-pushed the enh/add-occ-debug-command branch 3 times, most recently from e0056e8 to 06400d3 Compare April 5, 2025 21:50
ChristophWurst

This comment was marked as resolved.

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested & works

@ChristophWurst ChristophWurst requested a review from kesselb April 16, 2025 08:39
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
@st3iny st3iny force-pushed the enh/add-occ-debug-command branch from c587612 to 95a96c5 Compare April 17, 2025 12:20
Copy link
Member

@st3iny st3iny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works. I applied all suggestions, rebased and squashed.

@SebastianKrupinski
Copy link
Contributor Author

SebastianKrupinski commented Apr 17, 2025

Tested and works. I applied all suggestions, rebased and squashed.

This app.mail.debug will not work form the command line!!!!

So this command will not work,

NC_MAIL_DEBUG=true php occ mail:account:sync 14

@st3iny
Copy link
Member

st3iny commented Apr 17, 2025

Let's handle this in another PR then. You could add a check for the environment variable directly to the client factory.

@st3iny st3iny merged commit 68dd8c3 into main Apr 17, 2025
34 of 36 checks passed
@st3iny st3iny deleted the enh/add-occ-debug-command branch April 17, 2025 12:46
@github-project-automation github-project-automation bot moved this from 🏗️ In progress to ☑️ Done in 💌 📅 👥 Groupware team Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

4 participants