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

logging: configure default logging config #349

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied from Cylc, perhaps we should reduce this a little?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the amount of logging the UIS doesn't produce I feel that this is likely to be overkill.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon 100'000 bytes should be ~2000 lines worth of log file which seems plenty long enough.

Suggested change
'maxBytes': 10485760,
'maxBytes': 100000,

'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