Allow macOS logging addition to be copied to clipboard

This commit is contained in:
Tom Keffer
2023-12-24 17:18:15 -08:00
parent 00492024c0
commit 4e2ce168ca
2 changed files with 16 additions and 13 deletions

View File

@@ -105,7 +105,7 @@ that work with macOS 12.x or later are standalone handlers that log to files.
Fortunately, there is a simple workaround. Put this at the bottom of your
`weewx.conf` configuration file:
```
```{.ini .copy}
[Logging]
[[root]]
@@ -117,7 +117,7 @@ Fortunately, there is a simple workaround. Put this at the bottom of your
level = DEBUG
formatter = verbose
class = logging.handlers.TimedRotatingFileHandler
# File to log to:
# File to log to, relative to WEEWX_ROOT:
filename = log/{process_name}.log
# When to rotate:
when = midnight

View File

@@ -14,14 +14,6 @@ import weewx
from weeutil.weeutil import to_int
def add_user_path(config_dict):
"""add the path to the parent of the user directory to PYTHONPATH."""
root_dict = extract_roots(config_dict)
lib_dir = os.path.abspath(os.path.join(root_dict['USER_DIR'], '..'))
sys.path.append(lib_dir)
return lib_dir
def extract_roots(config_dict):
"""Get the location of the various root directories used by weewx.
The extracted paths are *absolute* paths. That is, they are no longer relative to WEEWX_ROOT.
@@ -51,7 +43,15 @@ def extract_roots(config_dict):
def initialize(config_dict, log_label):
"""Set debug, set up the logger, and add the user path"""
"""Set debug, set up the logger, and add the user path
Args:
config_dict(dict): The configuration dictionary
log_label(str): A label to be used in the log for this process
Returns:
tuple[str,str]: A tuple containing (WEEWX_ROOT, USER_ROOT)
"""
# Set weewx.debug as necessary:
weewx.debug = to_int(config_dict.get('debug', 0))
@@ -59,8 +59,11 @@ def initialize(config_dict, log_label):
# Customize the logging with user settings.
weeutil.logger.setup(log_label, config_dict)
root_dict = extract_roots(config_dict)
# Add the 'user' package to PYTHONPATH
user_dir = add_user_path(config_dict)
user_dir = os.path.abspath(os.path.join(root_dict['USER_DIR'], '..'))
sys.path.append(user_dir)
# Now we can import user.extensions
try:
@@ -69,4 +72,4 @@ def initialize(config_dict, log_label):
log = logging.getLogger(__name__)
log.error("Cannot load user extensions: %s", e)
return user_dir
return config_dict['WEEWX_ROOT'], user_dir