Commit Graph
1795 Commits
Author SHA1 Message Date
Athanasius b1d35e0579 Merge branch 'fix/639-crash-linux-unset-journal-dir' into develop 2020-07-27 18:12:40 +01:00
A_D 6ab4433c59 Add TODO regarding type config 2020-07-27 19:07:54 +02:00
A_D 1b543e5820 Dont crash when journal_dir is None
Ensures that journal_dir is always at least an empty string.

Fixes #639
2020-07-27 18:55:59 +02:00
Athanasius b17b3a4a72 Merge pull request #632 from A-UNDERSCORE-D/cleanup/eddb
Cleanup eddb plugin
2020-07-27 14:56:29 +01:00
A_D b27e4a3628 fixed tk import and type annotations 2020-07-27 15:15:56 +02:00
A_D cad5f72b0a updated type annotation 2020-07-27 15:15:55 +02:00
A_D 7b231fb244 removed unicode specifier from string
python3 strings are always unicode
2020-07-27 15:15:55 +02:00
A_D 07c43d3057 added type annotations to globals 2020-07-27 15:15:54 +02:00
A_D e0462d8719 Replaced complex oneliner with multiline if 2020-07-27 15:15:54 +02:00
A_D 37181264c9 Added newline after scope changes 2020-07-27 15:15:53 +02:00
A_D 4eed4404c6 Added Any type hint to this
Resolves most type warnings
2020-07-27 15:15:53 +02:00
A_D ab58aa6355 autoformatted file 2020-07-27 15:15:52 +02:00
Athanasius 9fcaeb5feb Merge pull request #630 from EDCD/enhancement/563-proper-logging
Enhancement/563 proper logging

Covers only a few files for now.  But let's get this merged so we can move on.
2020-07-27 11:07:50 +01:00
Athanasius 63f3859af4 Remove extraneous __class__ in logging strings 2020-07-27 10:56:57 +01:00
Athanasius 19e750eddd Use logger.exception() not log.error(.., exc_info=..) 2020-07-27 10:47:57 +01:00
Athanasius 6429cae932 Use isinstance() for type checking 2020-07-27 10:37:36 +01:00
Athanasius 6c9139e395 TODO: unittest hint about testing logging
And comment out the use of it here.
2020-07-27 10:35:08 +01:00
Athanasius d7c2372417 Flake8 cleanup round #2 2020-07-27 10:14:16 +01:00
Athanasius cbba1ce28a Change time string in translations.
It makes the code far too complicated to sub {HH} -> %H and the like.
2020-07-27 09:44:12 +01:00
Athanasius f9a23cc831 Clean up flake8 output for this branch 2020-07-27 09:37:10 +01:00
Athanasius 3653a1342f No need to subclass object. 2020-07-27 06:57:53 +01:00
Athanasius 307910739a Remove now un-necessary imports for logging/traceback 2020-07-27 06:57:53 +01:00
Athanasius 66e2c354c7 Documentation update and getLogger() -> get_logger()
* Technically %(class)s can be e.g. A.B not just 'B' so say "name(s)".
* To not confuse EDMCLogging.getLogger() with logging.getLogger() it's
 been renamed to get_logger().
* Note how we signal errors with finding class and/or qualname.
* Call out EDMCLogging.py in Contributing.md.
2020-07-27 06:57:53 +01:00
Athanasius 2eba647f17 Simply walk up the stack finding the frame we want.
Also leave that 'A.B' test around as a hint for a unittest.  Obviously
that instantiation will need commenting out for a release.
2020-07-27 06:57:53 +01:00
Athanasius 5a779a3379 Cleanups and docstrings
* Added/fleshed out docstrings on file, classes and functions.
* No need to use a function for the stack frame getting.
* Check if LogRecord has class or qualname before setting, allowing
 upstream to implement them.
* Use setattr()/getattr() rather than __dict__ fiddling.
* Force an error string into class/qualname if we have issues finding
 them, rather than failing silently to ''.
2020-07-27 06:57:53 +01:00
Athanasius 596527bda2 Move logging setup to EDMCLogging.py with a class
* Also now providers single caller_class_and_qualname() method to get
 both strings, returned as a Tuple[str, str].  Either could be empty
 if something went wrong.
* Rather than a fragile 'skip' this now:
    1. Looks for the first up-stack frame with self of logging.Logger
    1. Then looks for the next up-stack frame with self NOT of
     logging.Logger.  This should be the call site we want.
2020-07-27 06:57:53 +01:00
Athanasius c196a38e09 Add logging TODOs. logger creation & frame detection
* Nothing should "from EDMarketConnector import logger" any more, so
 we can move this back inside __main__ section
* We shouldn't rely on a magic number of frames to skip.  Detect the
 proper frame automatically.
2020-07-27 06:57:52 +01:00
Athanasius a82824c0e9 Contributing.md: Update logging docs for auto qualname and proper import 2020-07-27 06:57:52 +01:00
Athanasius 2e58d106bd logging.getLogger(appname) instead of import from EDMarketConnector
Using:

from EDMarketConnector import logger

causes issues if EDMarketConnector is already importing 'this' file.

So just get a logger using logger.getLogger(appname) instead.
`from config import appname` if needs be.
2020-07-27 06:57:52 +01:00
Athanasius bae2f25e19 companion.py: Convert to proper logging 2020-07-27 06:57:52 +01:00
Athanasius 2176187be7 Fix typos in class/qualname finders 2020-07-27 06:57:52 +01:00
Athanasius 8e1f3b8a90 plugins/inara: Fix typo on except: 2020-07-27 06:57:52 +01:00
Athanasius 7d060aa325 plugins/inara: Convert to proper logging 2020-07-27 06:57:52 +01:00
Athanasius 4d7f81cec1 Add emergency print()s if we can't find class/qualname 2020-07-27 06:57:52 +01:00
Athanasius 89cadbc0eb Add paranoia checks to class and qualname finders 2020-07-27 06:57:52 +01:00
Athanasius 7951463fba plugins/edsm: Converted to proper logging 2020-07-27 06:57:52 +01:00
Athanasius 6aa409388e plugins/eddn: Converted to proper logging 2020-07-27 06:57:52 +01:00
Athanasius 818bd89fd7 Remove un-necessary {__class__} from logging messages 2020-07-27 06:57:52 +01:00
Athanasius 5af87a5b98 Clean up EDMarketConnector.py after that qualname testing 2020-07-27 06:57:52 +01:00
Athanasius 6b9d4a11cb Use a logging.Filter to implement %(qualname)s in formatting.
This gets the function that called the logging, and if it's in a class
it looks up the function via getattr(<class>, <func name>) and then
uses __qualname__ to quickly get the fully qualified name.
2020-07-27 06:57:52 +01:00
Athanasius debc7f97d3 Use a logging.Filter to implement %(class)s in formatting. 2020-07-27 06:57:52 +01:00
Athanasius 2e12513c6c Changes plug.py to proper logging.
This relies on the logger.Formatter setup to fill in function name
rather than calling out exactly why we're logging.  It should be
obvious, i.e. if you're in plug.py:notify_journal_entry then the named
plugin threw an un-caught exception trying to call its method for this.
2020-07-27 06:57:52 +01:00
Athanasius 23b167fe66 Change startup version back to a print()
This is so early it doesn't need to be a spammy log message.
2020-07-27 06:57:27 +01:00
Athanasius fe0ff2498e Moves logger definition so it's import'able 2020-07-27 06:57:23 +01:00
Athanasius fa1443b49c Contributing.md: Document use of logging.
Also fixes some camelCase to be proper snake_case in an example.
2020-07-27 06:57:23 +01:00
Athanasius c971106c0e Convert print()s to logging & refactor help_about -> HelpAbout 2020-07-27 06:57:23 +01:00
Athanasius cd4216d19c logger setup and initialisation
* Initial printing of version is now a logger.info(...)
2020-07-26 23:16:52 +01:00
Athanasius e1752506c5 Move "only run once" code into def enforce_single_instance() 2020-07-26 23:16:52 +01:00
A_D 5aaf88b281 fix quoting style 2020-07-26 23:08:47 +01:00
A_D 87b7f639bb cleanup coriolis.py 2020-07-26 23:08:47 +01:00