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

CustomFormatter to remove rich markup in logfile #1482

Merged
merged 1 commit into from
May 22, 2023

Conversation

simonc56
Copy link
Collaborator

Removes rich markups link and green (used for titles) in logfile (keep them in console log) because it makes logfile unreadable.
Feature added in #1447 version 0.26.1

Logfile before this PR:

2023-05-12 04:20:11,431 INFO[PlexTraktSync]:Sync Show sections: ['[link=https꞉//app.plex.tv/desktop/#!/media/3f48753c4e05fda84b1316596945dd36194e4/com.plexapp.plugins.library?source=2][green]TV Shows[/][/]']
2023-05-12 04:21:01,117 INFO[PlexTraktSync]:Marking as watched in Plex: [link=https꞉//app.plex.tv/desktop/#!/server/3f48753c4e05fda84b1316596945dd36194e4/details?key=/library/metadata/5098][green]Breaking Bad/s01e04/Cancer Man (2008)[/][/]
2023-05-12 04:21:23,406 INFO[PlexTraktSync]:[link=https꞉//app.plex.tv/desktop/#!/media/3f48753c4e05fda84b1316596945dd36194e4/com.plexapp.plugins.library?source=2][green]TV Shows[/][/] processed in 1 min 5.3 seconds

Logfile after this PR:

2023-05-12 04:20:11,431 INFO[PlexTraktSync]:Sync Show sections: ['TV Shows']
2023-05-12 04:21:01,117 INFO[PlexTraktSync]:Marking as watched in Plex: Breaking Bad/s01e04/Cancer Man (2008)
2023-05-12 04:21:23,406 INFO[PlexTraktSync]:TV Shows processed in 1 min 5.3 seconds

@simonc56 simonc56 force-pushed the rich-no-markup-logfile branch from fdc108a to 79172e4 Compare May 14, 2023 17:16
@simonc56 simonc56 merged commit 299113e into Taxel:main May 22, 2023
@glensc
Copy link
Collaborator

glensc commented Jun 23, 2023

logging causes massive noise now

--- Logging error ---
Traceback (most recent call last):
  File 
"/opt/homebrew/Cellar/[email protected]/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/logging/__init__.py", 
line 1110, in emit
    msg = self.format(record)
          ^^^^^^^^^^^^^^^^^^^
  File 
"/opt/homebrew/Cellar/[email protected]/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/logging/__init__.py", 
line 953, in format
    return fmt.format(record)
           ^^^^^^^^^^^^^^^^^^
  File "PlexTraktSync/plextraktsync/logging.py", line 42, in format
    record.msg = self.remove_markup(record.msg)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "PlexTraktSync/plextraktsync/logging.py", line 47, in remove_markup
    return re.sub(pattern, '', text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/__init__.py", 
line 185, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'list'
Call stack:
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "PlexTraktSync/plextraktsync/__main__.py", line 18, in <module>
    cli()
  File "/lib/python3.11/site-packages/click/core.py", 
line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/lib/python3.11/site-packages/click/core.py", 
line 1055, in main
    rv = self.invoke(ctx)
  File "/lib/python3.11/site-packages/click/core.py", 
line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/lib/python3.11/site-packages/click/core.py", 
line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/lib/python3.11/site-packages/click/core.py", 
line 760, in invoke
    return __callback(*args, **kwargs)
  File "PlexTraktSync/plextraktsync/cli.py", line 25, in wrap
    cmd(*args, **kwargs)
  File "PlexTraktSync/plextraktsync/commands/sync.py", line 68, in sync
    runner.sync(walker=w, dry_run=config.dry_run)
  File "PlexTraktSync/plextraktsync/sync.py", line 65, in sync
    for movie in walker.find_movies():
  File "PlexTraktSync/plextraktsync/walker.py", line 279, in find_movies
    movie = self.mf.resolve_any(plex)
  File "PlexTraktSync/plextraktsync/media.py", line 252, in resolve_any
    m = self.resolve_guid(guid, show)
  File "PlexTraktSync/plextraktsync/media.py", line 274, in resolve_guid
    tm = self.trakt.find_by_guid(guid)
  File "PlexTraktSync/plextraktsync/trakt/TraktApi.py", line 225, in find_by_guid
    return self.search_by_id(guid.id, id_type=guid.provider, media_type=guid.type)
  File "PlexTraktSync/plextraktsync/decorators/rate_limit.py", line 22, in wrapper
    return fn(*args, **kwargs)
  File "PlexTraktSync/plextraktsync/decorators/retry.py", line 26, in wrapper
    return fn(*args, **kwargs)
  File "PlexTraktSync/plextraktsync/trakt/TraktApi.py", line 255, in search_by_id
    logger.debug([pm.to_json() for pm in search])

@glensc
Copy link
Collaborator

glensc commented Jun 24, 2023

Fixing it: #1512

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants