Skip to content
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

Projects plugin: distinguish between sub-projects in logging #6414

Closed
4 tasks done
alexvoss opened this issue Dec 1, 2023 · 30 comments
Closed
4 tasks done

Projects plugin: distinguish between sub-projects in logging #6414

alexvoss opened this issue Dec 1, 2023 · 30 comments
Labels
change request Issue requests a new feature or improvement resolved Issue is resolved, yet unreleased if open

Comments

@alexvoss
Copy link
Sponsor Collaborator

alexvoss commented Dec 1, 2023

Context

When building a project with subprojects through the Projects plugin, the log entries generated by the concurrent build processes for the subprojects are interleaved and it can be difficult to tell which subproject generated which message.

Description

The log entries for the subprojects should be tagged with the name of the subproject so the user can tell which subproject generated which message. They will still be interleaved, as shown below, but it will be possible to filter them with an appropriate log filtering tool.

INFO    -  Building documentation to directory:
           /home/avoss/src/mkdocs-material/examples/examples/color-palette-toggle/site
INFO    -  Building documentation to directory:
           /home/avoss/src/mkdocs-material/examples/examples/custom-colors/site
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory:
           /home/avoss/src/mkdocs-material/examples/examples/blog-rss/site
INFO    -  Doc file 'README.md' contains an unrecognized relative link
           '../fonts-custom', it was left as is.
INFO    -  Doc file 'README.md' contains an unrecognized relative link
           'blog/2023/10/11/my-first-blog-post', it was left as is.
INFO    -  Doc file 'README.md' contains an unrecognized relative link 'blog',
           it was left as is. Did you mean 'blog/index.md'?
INFO    -  Doc file 'README.md' contains an unrecognized relative link
           'blog/archive/2023', it was left as is. Did you mean
           'blog/archive/2023.md'?
INFO    -  Doc file 'README.md' contains an unrecognized relative link
           'blog/category/meta', it was left as is. Did you mean
           'blog/category/meta.md'?
INFO    -  Doc file 'README.md' contains an unrecognized relative link
           '../blog-basic', it was left as is.
INFO    -  Building documentation to directory:
           /home/avoss/src/mkdocs-material/examples/examples/fonts-custom/site
INFO    -  Documentation built in 0.40 seconds
INFO    -  Documentation built in 0.40 seconds
INFO    -  Documentation built in 0.37 seconds
INFO    -  Documentation built in 0.38 seconds
INFO    -  Documentation built in 0.41 seconds
INFO    -  Documentation built in 0.41 seconds

Note that the README file for blog-rss contains none of the links that MkDocs complains about here. Also, the summary of how much time each project took to build is ambiguous.

This will require some modification of the subproject settings, I assume, to instruct MkDocs to not just log to the console or to include the tag. I included a link below to some info on how to log in parallel processes. This should require a change both in the projects plugin and in MkDocs, I guess.

Related links

Use Cases

There are a couple of use cases that come to my mind:

  • figuring out which subprojects errors and warnings belong to
  • figuring out which subprojects take a long time to build

Visuals

No response

Before submitting

@squidfunk squidfunk added the change request Issue requests a new feature or improvement label Dec 1, 2023
@alexvoss
Copy link
Sponsor Collaborator Author

alexvoss commented Dec 1, 2023

One additional observation: for some reason, the logs of the subproject builds are shown on Linux but not on MacOS. That seems odd to me. Both are running the same 9.4.14+insiders.4.46.0 and MkDocs 1.5.3

@squidfunk
Copy link
Owner

Thanks for suggesting! Fixed in 588c7aa. Log messages of subprojects should now be prefixed at all times. I think I found a way to patch the MkDocs logger and prepend the slug while keeping all other formatting. It looks like this:

Bildschirm­foto 2023-12-03 um 18 05 42

The nice thing is that plugins like the blog plugin that show the file name and the folder in which it happened should now all show the relative path from where the project is built, i.e., languages/de/docs:

ERROR - [project://.de] Error reading metadata of post 'blog/posts/hallo-welt.md' in 'languages/de/docs':

Log messages are still interleaved, but I'm not sure what the best way is. Since the build is done in parallel, the only way to batch messages in consecutive chunks would be to wait for each project to complete and then flush log messages to stdout. I'm not sure that's a good idea, but if somebody comes up with a better idea, I'm happy to consider.

One additional observation: for some reason, the logs of the subproject builds are shown on Linux but not on MacOS. That seems odd to me. Both are running the same 9.4.14+insiders.4.46.0 and MkDocs 1.5.3

Indeed that is very weird. I also haven't observed them on macOS. Are they at least prefixed now? Might also be a difference or implementation issue in ProcessPoolExecutor or its configuration. If you find out why this is happening, please create an issue or a PR, so we can fix it. It's likely only a setting ☺️

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Dec 3, 2023
@alexvoss
Copy link
Sponsor Collaborator Author

alexvoss commented Dec 3, 2023

Log messages are still interleaved

I don't see how this could be done without a lot of effort and possible drawbacks. The tagging should be doing enough to address the problem of interpreting the log entries. Thanks for fixing this so quickly. I saw is was a fair bit of work.

On MacOS, I still don't see the log entries from the subprojects. There might be some documented OS-dependent behavior in concurrent.future? Is multiprocessing the underlying implementation? If so, might be worth looking there as well.

@squidfunk
Copy link
Owner

The screenshot above was taken on macOS – don't you see any log entries?

@alexvoss
Copy link
Sponsor Collaborator Author

alexvoss commented Dec 4, 2023

That is odd, let me run past you what I am doing:

$ pip install --upgrade git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git
[...stuff...]
$ git clone git@github.com:mkdocs-material/examples.git
Cloning into 'examples'...
remote: Enumerating objects: 1857, done.
remote: Counting objects: 100% (572/572), done.
remote: Compressing objects: 100% (244/244), done.
remote: Total 1857 (delta 287), reused 487 (delta 243), pack-reused 1285
Receiving objects: 100% (1857/1857), 1.02 MiB | 5.98 MiB/s, done.
Resolving deltas: 100% (919/919), done.
$ cd examples 
$ mkdocs serve
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  Documentation built in 0.74 seconds
INFO    -  [19:00:37] Watching paths for changes: 'docs', 'mkdocs.yml', 'examples/blog-basic/docs', 'examples/blog-basic/mkdocs.yml', 'examples/blog-rss/docs',
           'examples/blog-rss/mkdocs.yml', 'examples/blog-update/docs', 'examples/blog-update/mkdocs.yml', 'examples/color-palette-system-preference/docs',
           'examples/color-palette-system-preference/mkdocs.yml', 'examples/color-palette-toggle/docs', 'examples/color-palette-toggle/mkdocs.yml',
           'examples/cookie-consent/docs', 'examples/cookie-consent/mkdocs.yml', 'examples/custom-colors/docs', 'examples/custom-colors/mkdocs.yml',
           'examples/custom-cookies/docs', 'examples/custom-cookies/mkdocs.yml', 'examples/fonts-builtin/docs', 'examples/fonts-builtin/mkdocs.yml',
           'examples/fonts-custom/docs', 'examples/fonts-custom/mkdocs.yml', 'examples/page-status/docs', 'examples/page-status/mkdocs.yml', 'examples/tags/docs',
           'examples/tags/mkdocs.yml', 'examples/tags-with-icons/docs', 'examples/tags-with-icons/mkdocs.yml'
INFO    -  [19:00:37] Serving on http://127.0.0.1:8000/examples/
[...]
$ python --version
Python 3.12.0

@squidfunk
Copy link
Owner

squidfunk commented Dec 4, 2023

So if you put an unresolvable link in a markdown page in a project nothing happens? Sorry, I'm unable to reproduce this from the information I have. As you can see in the screenshot, works on my machine. We need to find out what is stopping this. We're still experiencing some problems with the cache (reopened the issue), so you might use:

plugins:
  - projects:
      cache: false

@alexvoss
Copy link
Sponsor Collaborator Author

alexvoss commented Dec 4, 2023

Right, it seems there is something deeper and more sinister going on:

$ git clone https://github.com/mkdocs-material/examples
Cloning into 'examples'...
remote: Enumerating objects: 1857, done.
remote: Counting objects: 100% (572/572), done.
remote: Compressing objects: 100% (244/244), done.
remote: Total 1857 (delta 287), reused 487 (delta 243), pack-reused 1285
Receiving objects: 100% (1857/1857), 1.02 MiB | 5.10 MiB/s, done.
Resolving deltas: 100% (919/919), done.
$ cd examples 
$ mkdocs build
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/avoss/src/mkdocs-material/reproduce/subprojects/examples/site
INFO    -  Creating archive 'color-palette-system-preference.zip'
INFO    -  Creating archive 'blog-basic.zip'
INFO    -  Creating archive 'page-status.zip'
INFO    -  Creating archive 'blog-rss.zip'
INFO    -  Creating archive 'tags-with-icons.zip'
INFO    -  Creating archive 'blog-update.zip'
INFO    -  Creating archive 'tags.zip'
INFO    -  Creating archive 'custom-cookies.zip'
INFO    -  Creating archive 'fonts-custom.zip'
INFO    -  Creating archive 'cookie-consent.zip'
INFO    -  Creating archive 'color-palette-toggle.zip'
INFO    -  Creating archive 'custom-colors.zip'
INFO    -  Creating archive 'fonts-builtin.zip'
INFO    -  Documentation built in 0.75 seconds
$ find . -name site
./site

The subprojects do not get built. That would explain the lack of log messages. I did not notice in my previous test because I assumed the projects were being built and just looked for the log messages.

Let me try this with a brand-new venv... Same result but I do note that MkDocs is complaining about the missing RSS plugin, so it is hitting the subprojects - but then not doing anything?

Caching is turned off in the examples repo btw.

Hope this helps. Let me know if you want me to try and debug this, esp. if you cannot reproduce this with the examples. Otherwise I will crack on with the stuff on PRs.

@squidfunk
Copy link
Owner

squidfunk commented Dec 4, 2023

Okay, so first of all, let's try to fix the logging problems. I've invested two hours into getting this right. Who would've though that this would be so challenging? I think I got all cases now, and introduced two new settings to the plugin:

  • log: boolean: Whether projects should log anything at all
  • log_level: "info" | "warn" | "error" | "debug": What level should plugins log to

The defaults:

plugins:
  - projects:
      log: true
      log_level: warn

MkDocs itself has two command line flags which influence logging:

  • --quiet: Sets the log level to "error". This is now also propagated to projects, so --quiet should turn of everything.
  • --verbose: Sets the log level o "debug". This is not propagated to projects, because it might be just too much to consume, but you can set it manually as described above.

Now, if I take the multilingual blog demo project that I posted earlier, I get the following outputs:

mkdocs buildlog: true, log_level: warn (defaults)

INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site
WARNING -  [project://.de] The "site_url" option is not set. The cards are generated, but not linked, so they won't be visible on social media.
WARNING -  [project://.en] Doc file 'blog/posts/hello-world.md' contains a relative link 'foo.md', but the target 'blog/posts/foo.md' is not found among
           documentation files.
WARNING -  [project://.de] Doc file 'blog/posts/hallo-welt.md' contains a relative link 'foo.md#dsa', but the target 'blog/posts/foo.md' is not found
           among documentation files.
WARNING -  [project://.de] Config value 'dev_addr': The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect
           to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready server
           instead.
INFO    -  Documentation built in 0.64 seconds

mkdocs buildlog: false, log_level: warn

INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site
INFO    -  Documentation built in 0.62 seconds

mkdocs buildlog: true, log_level: info

This is likely what you are (were?) seeing.

INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site
INFO    -  [project://.es] Cleaning site directory
INFO    -  [project://.es] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/es
INFO    -  [project://.es] Documentation built in 0.04 seconds
WARNING -  [project://.de] The "site_url" option is not set. The cards are generated, but not linked, so they won't be visible on social media.
INFO    -  [project://.en] Cleaning site directory
INFO    -  [project://.en] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/en
INFO    -  [project://.de] Cleaning site directory
INFO    -  [project://.de] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/de
WARNING -  [project://.en] Doc file 'blog/posts/hello-world.md' contains a relative link 'foo.md', but the target 'blog/posts/foo.md' is not found among
           documentation files.
WARNING -  [project://.de] Doc file 'blog/posts/hallo-welt.md' contains a relative link 'foo.md#dsa', but the target 'blog/posts/foo.md' is not found
           among documentation files.
INFO    -  [project://.en] Documentation built in 0.21 seconds
INFO    -  [project://.de] Documentation built in 0.23 seconds
WARNING -  [project://.de] Config value 'dev_addr': The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect
           to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready server
           instead.
INFO    -  Documentation built in 0.58 seconds

mkdocs buildlog: true, log_level: debug

INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site
DEBUG   -  [project://.de] Loaded theme configuration for 'material' from
           '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/mkdocs_theme.yml': {'language': 'en', 'direction': None,
           'features': [], 'font': {'text': 'Roboto', 'code': 'Roboto Mono'}, 'icon': None, 'favicon': 'assets/images/favicon.png', 'static_templates':
           ['404.html']}
DEBUG   -  [project://.es] Loaded theme configuration for 'mkdocs' from
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/themes/mkdocs/mkdocs_theme.yml': {'static_templates':
           ['404.html'], 'locale': 'en', 'include_search_page': False, 'search_index_only': False, 'highlightjs': True, 'hljs_languages': [], 'hljs_style':
           'github', 'navigation_depth': 2, 'nav_style': 'primary', 'analytics': {'gtag': None}, 'shortcuts': {'help': 191, 'next': 78, 'previous': 80, 'search':
           83}}
DEBUG   -  [project://.en] Loaded theme configuration for 'material' from
           '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/mkdocs_theme.yml': {'language': 'en', 'direction': None,
           'features': [], 'font': {'text': 'Roboto', 'code': 'Roboto Mono'}, 'icon': None, 'favicon': 'assets/images/favicon.png', 'static_templates':
           ['404.html']}
DEBUG   -  [project://.es] Running 1 `startup` events
DEBUG   -  [project://.es] Running 2 `config` events
DEBUG   -  [project://.es] Running 2 `pre_build` events
INFO    -  [project://.es] Cleaning site directory
INFO    -  [project://.es] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/es
DEBUG   -  [project://.es] Looking for translations for locale 'en'
DEBUG   -  [project://.es] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/contrib/search/templates/locales'
DEBUG   -  [project://.es] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.es] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/themes/mkdocs/locales'
DEBUG   -  [project://.es] Reading markdown pages.
DEBUG   -  [project://.es] Reading: index.md
DEBUG   -  [project://.es] Running 1 `env` events
DEBUG   -  [project://.es] Copying static assets.
DEBUG   -  [project://.es] Copying media file: 'css/base.css'
DEBUG   -  [project://.es] Copying media file: 'css/bootstrap.min.css'
DEBUG   -  [project://.es] Copying media file: 'css/font-awesome.min.css'
DEBUG   -  [project://.es] Copying media file: 'fonts/fontawesome-webfont.eot'
DEBUG   -  [project://.es] Copying media file: 'fonts/fontawesome-webfont.svg'
DEBUG   -  [project://.es] Copying media file: 'fonts/fontawesome-webfont.ttf'
DEBUG   -  [project://.es] Copying media file: 'fonts/fontawesome-webfont.woff'
DEBUG   -  [project://.es] Copying media file: 'fonts/fontawesome-webfont.woff2'
DEBUG   -  [project://.es] Copying media file: 'img/favicon.ico'
DEBUG   -  [project://.es] Copying media file: 'img/grid.png'
DEBUG   -  [project://.es] Copying media file: 'js/base.js'
DEBUG   -  [project://.es] Copying media file: 'js/bootstrap.min.js'
DEBUG   -  [project://.es] Copying media file: 'js/jquery-3.6.0.min.js'
DEBUG   -  [project://.es] Copying media file: 'search/lunr.js'
DEBUG   -  [project://.es] Copying media file: 'search/main.js'
DEBUG   -  [project://.es] Copying media file: 'search/worker.js'
DEBUG   -  [project://.es] Building theme template: 404.html
DEBUG   -  [project://.es] Running 1 `template_context` events
DEBUG   -  [project://.es] Building theme template: sitemap.xml
DEBUG   -  [project://.es] Running 1 `template_context` events
DEBUG   -  [project://.es] Gzipping template: sitemap.xml
DEBUG   -  [project://.es] Building markdown pages.
DEBUG   -  [project://.es] Building page index.md
DEBUG   -  [project://.es] Running 2 `page_context` events
DEBUG   -  [project://.es] Running 2 `post_build` events
INFO    -  [project://.es] Documentation built in 0.04 seconds
DEBUG   -  [project://.en] Running 4 `startup` events
DEBUG   -  [project://.de] Running 4 `startup` events
DEBUG   -  [project://.en] Running 4 `config` events
DEBUG   -  [project://.de] Running 4 `config` events
DEBUG   -  [project://.en] Looking for translations for locale 'en'
WARNING -  [project://.de] The "site_url" option is not set. The cards are generated, but not linked, so they won't be visible on social media.
DEBUG   -  [project://.en] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.de] Looking for translations for locale 'en'
DEBUG   -  [project://.en] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.de] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.de] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.en] Looking for translations for locale 'en'
DEBUG   -  [project://.en] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.en] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.de] Looking for translations for locale 'en'
DEBUG   -  [project://.de] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.de] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.en] Looking for translations for locale 'en'
DEBUG   -  [project://.en] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.en] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.en] Running 1 `pre_build` events
INFO    -  [project://.en] Cleaning site directory
INFO    -  [project://.en] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/en
DEBUG   -  [project://.en] Looking for translations for locale 'en'
DEBUG   -  [project://.en] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.en] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.de] Looking for translations for locale 'en'
DEBUG   -  [project://.de] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.de] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.de] Running 1 `pre_build` events
INFO    -  [project://.de] Cleaning site directory
INFO    -  [project://.de] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/de
DEBUG   -  [project://.de] Looking for translations for locale 'en'
DEBUG   -  [project://.de] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.de] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.en] Running 2 `files` events
DEBUG   -  [project://.en] Running 1 `nav` events
DEBUG   -  [project://.en] Looking for translations for locale 'en'
DEBUG   -  [project://.en] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.en] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.en] Looking for translations for locale 'en'
DEBUG   -  [project://.en] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.en] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.de] Running 3 `files` events
DEBUG   -  [project://.de] Running 1 `nav` events
DEBUG   -  [project://.de] Looking for translations for locale 'en'
DEBUG   -  [project://.de] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.de] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.en] Reading markdown pages.
DEBUG   -  [project://.en] Reading: index.md
DEBUG   -  [project://.en] Running 2 `page_markdown` events
DEBUG   -  [project://.de] Looking for translations for locale 'en'
DEBUG   -  [project://.de] No translations found here:
           '/Users/squidfunk/Downloads/multi-language-blog/venv/lib/python3.11/site-packages/mkdocs/templates/locales'
DEBUG   -  [project://.de] No translations found here: '/Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/insiders/material/templates/locales'
DEBUG   -  [project://.de] Reading markdown pages.
DEBUG   -  [project://.de] Reading: index.md
DEBUG   -  [project://.de] Running 3 `page_markdown` events
DEBUG   -  [project://.en] Running 1 `page_content` events
DEBUG   -  [project://.en] Reading: blog/index.md
DEBUG   -  [project://.en] Running 2 `page_markdown` events
DEBUG   -  [project://.en] Running 1 `page_content` events
DEBUG   -  [project://.en] Reading: blog/posts/hello-world.md
DEBUG   -  [project://.en] Running 2 `page_markdown` events
WARNING -  [project://.en] Doc file 'blog/posts/hello-world.md' contains a relative link 'foo.md', but the target 'blog/posts/foo.md' is not found among
           documentation files.
DEBUG   -  [project://.en] Running 1 `page_content` events
DEBUG   -  [project://.en] Reading: blog/archive/2023.md
DEBUG   -  [project://.en] Running 2 `page_markdown` events
DEBUG   -  [project://.en] Running 1 `page_content` events
DEBUG   -  [project://.en] Running 2 `env` events
DEBUG   -  [project://.en] Copying static assets.
DEBUG   -  [project://.en] Building theme template: 404.html
DEBUG   -  [project://.en] Running 1 `template_context` events
DEBUG   -  [project://.de] Running 1 `page_content` events
DEBUG   -  [project://.de] Reading: blog/index.md
DEBUG   -  [project://.de] Running 3 `page_markdown` events
DEBUG   -  [project://.de] Running 1 `page_content` events
DEBUG   -  [project://.de] Reading: blog/posts/hallo-welt.md
DEBUG   -  [project://.de] Running 3 `page_markdown` events
WARNING -  [project://.de] Doc file 'blog/posts/hallo-welt.md' contains a relative link 'foo.md#dsa', but the target 'blog/posts/foo.md' is not found
           among documentation files.
DEBUG   -  [project://.de] Running 1 `page_content` events
DEBUG   -  [project://.de] Reading: blog/archive/2023.md
DEBUG   -  [project://.de] Running 3 `page_markdown` events
DEBUG   -  [project://.de] Running 1 `page_content` events
DEBUG   -  [project://.de] Reading: blog/category/foo.md
DEBUG   -  [project://.de] Running 3 `page_markdown` events
DEBUG   -  [project://.de] Running 1 `page_content` events
DEBUG   -  [project://.de] Running 2 `env` events
DEBUG   -  [project://.de] Copying static assets.
DEBUG   -  [project://.de] Copying media file: '152389683.png'
DEBUG   -  [project://.de] Building theme template: sitemap.xml
DEBUG   -  [project://.de] Running 1 `template_context` events
DEBUG   -  [project://.de] Gzipping template: sitemap.xml
DEBUG   -  [project://.de] Building theme template: 404.html
DEBUG   -  [project://.de] Running 1 `template_context` events
DEBUG   -  [project://.en] Building theme template: sitemap.xml
DEBUG   -  [project://.en] Running 1 `template_context` events
DEBUG   -  [project://.en] Gzipping template: sitemap.xml
DEBUG   -  [project://.en] Building markdown pages.
DEBUG   -  [project://.en] Building page index.md
DEBUG   -  [project://.en] Running 3 `page_context` events
DEBUG   -  [project://.en] Running 1 `post_page` events
DEBUG   -  [project://.en] Copying media file: 'assets/images/social/index.png'
DEBUG   -  [project://.de] Building markdown pages.
DEBUG   -  [project://.de] Building page index.md
DEBUG   -  [project://.de] Running 3 `page_context` events
DEBUG   -  [project://.en] Building page blog/index.md
DEBUG   -  [project://.en] Running 3 `page_context` events
DEBUG   -  [project://.en] Doc file 'blog/posts/hello-world.md' contains a relative link 'foo.md', but the target 'blog/posts/foo.md' is not found among
           documentation files.
DEBUG   -  [project://.de] Running 1 `post_page` events
DEBUG   -  [project://.de] Copying media file: 'assets/images/social/index.png'
DEBUG   -  [project://.de] Building page blog/index.md
DEBUG   -  [project://.en] Running 1 `post_page` events
DEBUG   -  [project://.en] Copying media file: 'assets/images/social/blog/index.png'
DEBUG   -  [project://.de] Running 3 `page_context` events
DEBUG   -  [project://.en] Building page blog/posts/hello-world.md
DEBUG   -  [project://.de] Doc file 'blog/posts/hallo-welt.md' contains a relative link 'foo.md#dsa', but the target 'blog/posts/foo.md' is not found
           among documentation files.
DEBUG   -  [project://.en] Running 3 `page_context` events
DEBUG   -  [project://.en] Running 1 `post_page` events
DEBUG   -  [project://.en] Copying media file: 'assets/images/social/blog/2023/12/02/hello-world.png'
DEBUG   -  [project://.en] Building page blog/archive/2023.md
DEBUG   -  [project://.en] Running 3 `page_context` events
DEBUG   -  [project://.en] Doc file 'blog/posts/hello-world.md' contains a relative link 'foo.md', but the target 'blog/posts/foo.md' is not found among
           documentation files.
DEBUG   -  [project://.en] Running 1 `post_page` events
DEBUG   -  [project://.en] Copying media file: 'assets/images/social/blog/archive/2023.png'
DEBUG   -  [project://.en] Running 2 `post_build` events
INFO    -  [project://.en] Documentation built in 0.19 seconds
DEBUG   -  [project://.en] Running 2 `shutdown` events
DEBUG   -  [project://.de] Running 1 `post_page` events
DEBUG   -  [project://.de] Copying media file: 'assets/images/social/blog/index.png'
DEBUG   -  [project://.de] Building page blog/posts/hallo-welt.md
DEBUG   -  [project://.de] Running 3 `page_context` events
DEBUG   -  [project://.de] Running 1 `post_page` events
DEBUG   -  [project://.de] Copying media file: 'assets/images/social/blog/2023/12/02/hallo-welt.png'
DEBUG   -  [project://.de] Building page blog/archive/2023.md
DEBUG   -  [project://.de] Running 3 `page_context` events
DEBUG   -  [project://.de] Doc file 'blog/posts/hallo-welt.md' contains a relative link 'foo.md#dsa', but the target 'blog/posts/foo.md' is not found
           among documentation files.
DEBUG   -  [project://.de] Running 1 `post_page` events
DEBUG   -  [project://.de] Copying media file: 'assets/images/social/blog/archive/2023.png'
DEBUG   -  [project://.de] Building page blog/category/foo.md
DEBUG   -  [project://.de] Running 3 `page_context` events
DEBUG   -  [project://.de] Doc file 'blog/posts/hallo-welt.md' contains a relative link 'foo.md#dsa', but the target 'blog/posts/foo.md' is not found
           among documentation files.
DEBUG   -  [project://.de] Running 1 `post_page` events
DEBUG   -  [project://.de] Copying media file: 'assets/images/social/blog/category/foo.png'
DEBUG   -  [project://.de] Running 2 `post_build` events
INFO    -  [project://.de] Documentation built in 0.21 seconds
DEBUG   -  [project://.de] Running 2 `shutdown` events
WARNING -  [project://.de] Config value 'dev_addr': The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect
           to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready server
           instead.
INFO    -  Documentation built in 0.64 seconds

mkdocs build --quietlog: true, log_level: warn (defaults)

Nothing

Changes are in 27eb106. Can you confirm?

@squidfunk
Copy link
Owner

I'm going to work the rest of the day on two other problems: hoisting and caching. There are configurations where hoisting does not work as expected. I'm quite sure I know where this is coming from. I also have an idea how to mitigate the caching problems, but I'm not sure I'm able to fix this today.

@squidfunk
Copy link
Owner

squidfunk commented Dec 4, 2023

FYI, when I run mkdocs build with the latest changes on the Insiders repository and set log_level: info, I can see that the sub projects are in fact built correctly:

INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site
INFO    -  [project://.blog-update] Cleaning site directory
INFO    -  [project://.blog-update] Building documentation to directory:
           /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/blog-update
INFO    -  [project://.color-palette-toggle] Cleaning site directory
INFO    -  [project://.color-palette-toggle] Building documentation to directory:
           /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/color-palette-toggle
INFO    -  [project://.cookie-consent] Cleaning site directory
INFO    -  [project://.cookie-consent] Building documentation to directory:
           /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/cookie-consent
INFO    -  [project://.custom-colors] Cleaning site directory
INFO    -  [project://.custom-colors] Building documentation to directory:
           /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/custom-colors
INFO    -  [project://.blog-basic] Cleaning site directory
INFO    -  [project://.blog-basic] Building documentation to directory:
           /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/blog-basic
INFO    -  [project://.color-palette-system-preference] Cleaning site directory
INFO    -  [project://.color-palette-system-preference] Building documentation to directory:
           /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/color-palette-system-preference
INFO    -  [project://.blog-update] Doc file 'README.md' contains an unrecognized relative link 'blog/2023/10/11/my-first-blog-post', it was left as is.
INFO    -  [project://.blog-update] Doc file 'README.md' contains an unrecognized relative link 'blog', it was left as is. Did you mean 'blog/index.md'?
INFO    -  [project://.blog-update] Doc file 'README.md' contains an unrecognized relative link 'blog/archive/2023', it was left as is. Did you mean
           'blog/archive/2023.md'?
INFO    -  [project://.blog-update] Doc file 'README.md' contains an unrecognized relative link 'blog/category/meta', it was left as is. Did you mean
           'blog/category/meta.md'?
INFO    -  [project://.blog-update] Doc file 'README.md' contains an unrecognized relative link '../blog-basic', it was left as is.
INFO    -  [project://.blog-rss] Cleaning site directory
INFO    -  [project://.blog-rss] Building documentation to directory: /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/blog-rss
INFO    -  [project://.color-palette-toggle] Documentation built in 0.27 seconds
INFO    -  [project://.custom-cookies] Cleaning site directory
INFO    -  [project://.custom-cookies] Building documentation to directory:
           /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/custom-cookies
INFO    -  [project://.cookie-consent] Documentation built in 0.27 seconds
INFO    -  [project://.color-palette-system-preference] Documentation built in 0.28 seconds
INFO    -  [project://.fonts-builtin] Cleaning site directory
INFO    -  [project://.fonts-builtin] Building documentation to directory:
           /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/fonts-builtin
INFO    -  [project://.custom-colors] Documentation built in 0.27 seconds
INFO    -  [project://.blog-update] Documentation built in 0.34 seconds
INFO    -  [project://.fonts-custom] Cleaning site directory
INFO    -  [project://.fonts-custom] Building documentation to directory:
           /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/fonts-custom
INFO    -  [project://.page-status] Cleaning site directory
INFO    -  [project://.page-status] Building documentation to directory:
           /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/page-status
INFO    -  [project://.blog-basic] Documentation built in 0.36 seconds
INFO    -  [project://.tags] Cleaning site directory
INFO    -  [project://.tags] Building documentation to directory: /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/tags
INFO    -  [project://.fonts-builtin] Doc file 'README.md' contains an unrecognized relative link '../fonts-custom', it was left as is.
INFO    -  [project://.tags-with-icons] Cleaning site directory
INFO    -  [project://.tags-with-icons] Building documentation to directory:
           /Users/squidfunk/.workspace/squidfunk/repos/mkdocs-material/examples/site/tags-with-icons
INFO    -  [project://.fonts-custom] Doc file 'README.md' contains an unrecognized relative link '../fonts-builtin', it was left as is.
INFO    -  [project://.custom-cookies] Documentation built in 0.24 seconds
INFO    -  [project://.fonts-builtin] Documentation built in 0.22 seconds
INFO    -  [project://.blog-rss] Documentation built in 0.44 seconds
INFO    -  [project://.page-status] Documentation built in 0.23 seconds
INFO    -  [project://.fonts-custom] Documentation built in 0.28 seconds
INFO    -  [project://.tags] Documentation built in 0.25 seconds
INFO    -  [project://.tags-with-icons] Documentation built in 0.23 seconds
INFO    -  Creating archive 'color-palette-system-preference.zip'
INFO    -  Creating archive 'blog-basic.zip'
INFO    -  Creating archive 'page-status.zip'
INFO    -  Creating archive 'blog-rss.zip'
INFO    -  Creating archive 'tags-with-icons.zip'
INFO    -  Creating archive 'blog-update.zip'
INFO    -  Creating archive 'tags.zip'
INFO    -  Creating archive 'custom-cookies.zip'
INFO    -  Creating archive 'fonts-custom.zip'
INFO    -  Creating archive 'cookie-consent.zip'
INFO    -  Creating archive 'color-palette-toggle.zip'
INFO    -  Creating archive 'custom-colors.zip'
INFO    -  Creating archive 'fonts-builtin.zip'
INFO    -  Documentation built in 1.06 seconds

Edit: Updated after fixing the duplicate logging bug.

@squidfunk
Copy link
Owner

Okay, that is pretty frickin' cool. With the latest commit, you can change the log_level setting while mkdocs serve is running. Sometimes, I'm surprised by my own work hahahaha.

@squidfunk
Copy link
Owner

squidfunk commented Dec 4, 2023

One other odd thing: projects seem to be built multiple times. This was just uncovered by logging. I'll look into that as well.

Edit: this only seems to happen on the examples reposistory, not on my other test case.
Edit 2: Setting concurrency: 1 makes this also reproducible on the other project. Investigating.

@squidfunk
Copy link
Owner

squidfunk commented Dec 4, 2023

Okay, projects have not been built multiple times, but the loggers must be unregistered after completion, which I fixed in 443fa24. Now, when setting concurrency: 1, it's clear that projects are built in series.

Now

INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site
WARNING -  [project://.de] The "site_url" option is not set. The cards are generated, but not linked, so they won't be visible on social media.
INFO    -  [project://.de] Cleaning site directory
INFO    -  [project://.de] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/de
WARNING -  [project://.de] Doc file 'blog/posts/hallo-welt.md' contains a relative link 'foo.md#dsa', but the target 'blog/posts/foo.md' is not found
           among documentation files.
INFO    -  [project://.de] Documentation built in 0.24 seconds
WARNING -  [project://.de] Config value 'dev_addr': The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect
           to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready server
           instead.
INFO    -  [project://.en] Cleaning site directory
INFO    -  [project://.en] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/en
WARNING -  [project://.en] Doc file 'blog/posts/hello-world.md' contains a relative link 'foo.md', but the target 'blog/posts/foo.md' is not found among
           documentation files.
INFO    -  [project://.en] Documentation built in 0.26 seconds
INFO    -  [project://.es] Cleaning site directory
INFO    -  [project://.es] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/es
INFO    -  [project://.es] Documentation built in 0.03 seconds
INFO    -  Documentation built in 0.94 seconds

Before

INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site
BUILD .de
WARNING -  [project://.de] The "site_url" option is not set. The cards are generated, but not linked, so they won't be visible on social media.
INFO    -  [project://.de] Cleaning site directory
INFO    -  [project://.de] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/de
WARNING -  [project://.de] Doc file 'blog/posts/hallo-welt.md' contains a relative link 'foo.md#dsa', but the target 'blog/posts/foo.md' is not found
           among documentation files.
INFO    -  [project://.de] Documentation built in 0.22 seconds
BUILD .en
WARNING -  [project://.de] Config value 'dev_addr': The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect
           to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready server
           instead.
INFO    -  [project://.de] Cleaning site directory
INFO    -  [project://.en] Cleaning site directory
INFO    -  [project://.de] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/en
INFO    -  [project://.en] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/en
WARNING -  [project://.de] Doc file 'blog/posts/hello-world.md' contains a relative link 'foo.md', but the target 'blog/posts/foo.md' is not found among
           documentation files.
WARNING -  [project://.en] Doc file 'blog/posts/hello-world.md' contains a relative link 'foo.md', but the target 'blog/posts/foo.md' is not found among
           documentation files.
INFO    -  [project://.de] Documentation built in 0.18 seconds
INFO    -  [project://.en] Documentation built in 0.18 seconds
BUILD .es
INFO    -  [project://.de] Cleaning site directory
INFO    -  [project://.en] Cleaning site directory
INFO    -  [project://.es] Cleaning site directory
INFO    -  [project://.de] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/es
INFO    -  [project://.en] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/es
INFO    -  [project://.es] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/es
INFO    -  [project://.de] Documentation built in 0.03 seconds
INFO    -  [project://.en] Documentation built in 0.03 seconds
INFO    -  [project://.es] Documentation built in 0.03 seconds
INFO    -  Documentation built in 0.84 seconds

@alexvoss
Copy link
Sponsor Collaborator Author

alexvoss commented Dec 4, 2023

Question: you said at some point that it seemed projects were built more than once. Could that explain why I expected to see site/ in the examples subprojects when, in fact, I should have been looking for the single site/ in the main project? I saw site/ for all subprojects and I am sure I did not build them all manually outside the context of the projects plugin.

The bit about concurrency is great, that should help with debugging any issues people have, so got to make sure to include this in the documentation.

This is looking very nice now, indeed. Let me poke it a bit. I will hop back to my Mac and see if the very latest has changed anything there. You still want verification of the behavior in the different logging cases, I assume.

Edit: switching back to Linux because I still get no log output on my Mac. Mysterious but I agree we should focus on the new log functionality as this problem I see does not seem to be reproducible on other machines. Perhaps I should just reboot and see if it is one of those very odd quirks. Dunno, like I switched timezones since last reboot and this confuses the filesystem watcher or something.

@squidfunk
Copy link
Owner

Question: you said at some point that it seemed projects were built more than once.

That was debunked – it was a logging issue.

Could that explain why I expected to see site/ in the examples subprojects when, in fact, I should have been looking for the single site/ in the main project?

Where site ends up depends on what you do: serve or build. When serving, site is part of the subprojects, and symlinked into the top-level site directory, because we only want to build what changed and keep all intermediary results. Currently, all projects will always be built at least once, but we will add functionality to the plugin where it will only build projects if they changed. However, for this, we first need to get caching right, which is particularly tricky in that case – and I thought social cards are tricky.

When building the site, the projects are always built fresh in their resolved subpath in the top-level directory, so you end up with one nice deployable artifact without symlinks. So. Serving: symlinks. Building: hoisting to the top-level.

Also note that symlinks are necessary, because you might have projects inside projects, and projects are currently not built in topological order, but concurrently all at the same time. In the future, we will also introduce the possibility to build projects in topological order. This might be particularly helpful for when you have intermediate index pages in level 2 projects that are generated from level 3 projects.

I invite you to study the source of the projects plugin. It is extensively documented with the things that need to be considered when building multiple MkDocs projects together.

The bit about concurrency is great, that should help with debugging any issues people have, so got to make sure to include this in the documentation.

Jup. A as a rule for all concurrent plugins (social, privacy, optimize, projects) – setting concurrency: 1 will make the output much more readable. I'm unsure where we should put this, but maybe somewhere under "contributing".

Edit: switching back to Linux because I still get no log output on my Mac. Mysterious but I agree we should focus on the new log functionality as this problem I see does not seem to be reproducible on other machines. Perhaps I should just reboot and see if it is one of those very odd quirks. Dunno, like I switched timezones since last reboot and this confuses the filesystem watcher or something.

Hmm. Even not with mkdocs build --verbose or mkdocs serve --verbose? Could you try this on another shell, to be sure that there's nothing else interfering?

@alexvoss
Copy link
Sponsor Collaborator Author

alexvoss commented Dec 4, 2023

Could you try this on another shell, to be sure that there's nothing else interfering?

I have switched shells and also created new venvs and cloned the examples repo again. Let me figure this one out - unless someone reports they have a similar issue. I can figure up the debugger but want to first check that the logging options work ok, which I can do on the Linux box across the room.

@squidfunk
Copy link
Owner

https://xkcd.com/349/

@alexvoss
Copy link
Sponsor Collaborator Author

alexvoss commented Dec 4, 2023

I am beginning to suspect you put a feature flag in. if user == Alex then mess_with_him() ;o)

I now get no log output on Linux either and I am testing with both the examples repo and the multilingual blog zip you posted over in #2346 (reply in thread).

$ unzip ~/Downloads/multi-language-blog.zip
$ mkdocs build
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /home/avoss/src/mkdocs-material/reproduce/logs/multiling/site
INFO    -  Documentation built in 0.36 seconds
$ ls site/
404.html  assets  de  en  index.html  sitemap.xml  sitemap.xml.gz

Don't waste more of your time on this. I will eventually figure out what is going on and will send back some input that is actually usable. Just let me know if the problem is that my expectations are wrong about what the default behavior should be.

Edit: ok, the assumption that was wrong was that the multiling zip file would already contain the broken links. Now we are getting somewhere...

@squidfunk
Copy link
Owner

squidfunk commented Dec 4, 2023

I messed with the example to get some test output. Sorry, my fault. Here's the one I'm currently using (which is a mess):
projects-blog-example.zip

@alexvoss
Copy link
Sponsor Collaborator Author

alexvoss commented Dec 4, 2023

Here is one observation: the log entries produced by the individual examples are at the INFO level while the broken links are WARNINGs. I get the WARNINGs from the zip file you just sent fine on both Linux and MacOS. Let me see again about the examples to see what was going on with those.

@alexvoss
Copy link
Sponsor Collaborator Author

alexvoss commented Dec 4, 2023

Right, so [borken link](foo/) produces no log output when run through the projects plugin but this when run individually:

INFO    -  Doc file 'README.md' contains an unrecognized relative link 'foo/', it was left as is.

I expected to see this in the output when building with projects. If I change the link target to foo.md then it becomes a page that is referenced but does not exist in the project and I get a warning, which I actually get twice - once with the project tag and once without. Hope this helps. LMK if you want a reproduction or anything else.

@squidfunk
Copy link
Owner

That sounds perfect! You will only get the INFO messages after my latest refactoring when you set:

plugins:
  - projects:
      log_level: info

If that switches them on and off on both systems, we should have it.

@alexvoss
Copy link
Sponsor Collaborator Author

alexvoss commented Dec 4, 2023

There is then the question why the thing I was looking for is not a WARNING but that would go to MkDocs, I assume?

@squidfunk
Copy link
Owner

squidfunk commented Dec 4, 2023

If I change the link target to foo.md then it becomes a page that is referenced but does not exist in the project and I get a warning, which I actually get twice - once with the project tag and once without. Hope this helps. LMK if you want a reproduction or anything else.

Erm, could you paste the output? I don't get a double warning. Double warnings for log output should not occur.

@squidfunk
Copy link
Owner

If I set log_level: info and paste an unrecognized link, I correctly get:

INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site
INFO    -  [project://.es] Cleaning site directory
INFO    -  [project://.es] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/es
INFO    -  [project://.es] Documentation built in 0.04 seconds
WARNING -  [project://.de] The "site_url" option is not set. The cards are generated, but not linked, so they won't be visible on social media.
INFO    -  [project://.en] Cleaning site directory
INFO    -  [project://.en] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/en
INFO    -  [project://.de] Cleaning site directory
INFO    -  [project://.de] Building documentation to directory: /Users/squidfunk/Downloads/multi-language-blog/site/de
WARNING -  [project://.en] Doc file 'blog/posts/hello-world.md' contains a relative link 'foo.md', but the target 'blog/posts/foo.md' is not found among
           documentation files.
WARNING -  [project://.de] Doc file 'blog/posts/hallo-welt.md' contains a relative link 'foo.md#dsa', but the target 'blog/posts/foo.md' is not found
           among documentation files.
INFO    -  [project://.de] Doc file 'blog/posts/hallo-welt.md' contains an unrecognized relative link 'foo-bar/', it was left as is.
INFO    -  [project://.en] Documentation built in 0.18 seconds
INFO    -  [project://.de] Documentation built in 0.19 seconds
WARNING -  [project://.de] Config value 'dev_addr': The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect
           to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready server
           instead.
INFO    -  Documentation built in 0.55 seconds

No double messages.

@alexvoss
Copy link
Sponsor Collaborator Author

alexvoss commented Dec 4, 2023

I just ran another upgrade of the Insiders version, just to make sure:

Resolved https://****@github.com/squidfunk/mkdocs-material-insiders.git to commit c0f057ff4b54f810bb9145f8d421d06b2d26760d

The input is simply this index page for the English version with a broken page reference:

# Home

[Click here to read our blog](blog/index.md)

[borken link](foo.md)

then:

$ mkdocs build
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /home/avoss/src/mkdocs-material/reproduce/logs/project-blog/site
WARNING -  Doc file 'index.md' contains a relative link 'foo.md', but the target is not found among documentation files.
WARNING -  [project://.en] Doc file 'index.md' contains a relative link 'foo.md', but the target is not found among documentation
           files.

@squidfunk
Copy link
Owner

The latest commit switches the default log level to info. It might indeed be a better idea to use this log level, because it's likely less astonishing then defaulting to warn. Note that the unrecorgnized_links log level can be set to warn as well in mkdocs.yml, which would make them warnings, but this is extra configuration that we cannot assume to be in-place.

@squidfunk squidfunk removed the resolved Issue is resolved, yet unreleased if open label Dec 4, 2023
@squidfunk
Copy link
Owner

So, it's confirmed – somehow the logger prints twice on Linux. I'll investigate.

@squidfunk
Copy link
Owner

Fixed in 7eb51b7. I spun up a Docker instance and yes, there's duplicate logging in place. Funnily, log.hasHandler returns True on Linux while it returns False on macOS. I'm not sure whether this is an inconsistency in the Python logging module or in MkDocs. If there is a handler registered, we just override the color formatter when building nested projects. My testing shows that the issue should be gone now.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Dec 5, 2023
@squidfunk
Copy link
Owner

Released as part of 9.5.1+insiders-4.47.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change request Issue requests a new feature or improvement resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants