Skip to content

Commit

Permalink
Merge pull request #349 from oliver-sanders/logging-config-2
Browse files Browse the repository at this point in the history
logging: configure default logging config
  • Loading branch information
wxtim authored Jun 14, 2022
2 parents 4373c0c + 0860732 commit 9f0e55d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ ones in. -->

Internal changes, see https://github.com/cylc/cylc-uiserver/milestone/11?closed=1

-------------------------------------------------------------------------------
## __cylc-uiserver-1.1.0 (<span actions:bind='release-date'>Pending Release</span>)__

### Enhancements

[#349](https://github.com/cylc/cylc-uiserver/pull/349) -
Configure default logging. The UIServer log now goes to
`~/.cylc/uiserver/uiserver.log` at the `INFO` level by default. See the
Traitlets `logging_config` "trait" for more information.

-------------------------------------------------------------------------------
## __cylc-uiserver-1.0.1 (<span actions:bind='release-date'>Released 2022-03-23</span>)__

Expand Down
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)

# Transitive dependencies that we directly (lightly) use:
pyzmq
Expand Down

0 comments on commit 9f0e55d

Please sign in to comment.