Skip to content

Commit

Permalink
logging: configure default logging config
Browse files Browse the repository at this point in the history
* Bump Traitlets to >=5.2.1 (needed for logging_config) trait.
* Add default logging config to write to ~/.cylc/uiserver/uiserver.log
  at the INFO level.
* Document in the readme for now.
  • Loading branch information
oliver-sanders committed May 17, 2022
1 parent 0692266 commit 7e6dbaf
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ Jupyter Server can run multiple extensions. To control the extensions that
are run use the `ServerApp.jpserver_extensions` configuration, see the
[Jupyter Server configuration documentation](https://jupyter-server.readthedocs.io/en/latest/other/full-config.html#other-full-config).

By default the Cylc part of the UI Server log is written to
`~/.cylc/uiserver/uiserver.log`.

<!--
TODO: Link to Jupyter Server logging_config docs when published
-->

### UI

The UI can be configured via the "Settings" option in the Dashboard.
Expand Down
32 changes: 31 additions & 1 deletion cylc/uiserver/jupyter_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,38 @@
)
]

# store the JupyterHub runtime files in ~/.cylc/hub
# store JupyterHub runtime files in the user config directory
USER_CONF_ROOT.mkdir(parents=True, exist_ok=True)
c.JupyterHub.cookie_secret_file = f'{USER_CONF_ROOT / "cookie_secret"}'
c.JupyterHub.db_url = f'{USER_CONF_ROOT / "jupyterhub.sqlite"}'
c.ConfigurableHTTPProxy.pid_file = f'{USER_CONF_ROOT / "jupyterhub-proxy.pid"}'

# write Cylc logging to the user config directory
# NOTE: Parallel UIS instances will conflict over this file.
# See https://github.com/cylc/cylc-uiserver/issues/240
c.CylcUIServer.logging_config = {
'version': 1,
'handlers': {
'file': {
'class': 'logging.handlers.RotatingFileHandler',
'level': 'INFO',
'filename': str(USER_CONF_ROOT / 'uiserver.log'),
'mode': 'a',
'backupCount': 5,
'maxBytes': 10485760,
'formatter': 'file_fmt',
},
},
'loggers': {
'CylcUIServer': {
'level': 'INFO',
'handlers': ['console', 'file'],
},
},
'formatters': {
'file_fmt': {
'format': '%(asctime)s %(levelname)-8s %(message)s',
'datefmt': '%Y-%m-%dT%H:%M:%S',
}
},
}
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ install_requires =
graphql-ws==0.4.4
jupyter_server>=1.10.2
tornado>=6.1.0 # matches jupyter_server value
traitlets>=5
traitlets>=5.2.1 # required for logging_config (5.2.0 had bugs)

# Fix lack of upper pin for rx in graphql-core<2.3.0 (remove when
# upgrading graphene to 3.0):
Expand Down

0 comments on commit 7e6dbaf

Please sign in to comment.