gen3logging 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,360 @@
1
+ """
2
+ Logging with a standardized format
3
+ """
4
+
5
+ import json
6
+ import logging
7
+ import os
8
+ import sys
9
+ import time
10
+ from types import MappingProxyType
11
+ from typing import TextIO
12
+
13
+ FORMAT = "[%(asctime)s][%(name)10s][%(levelname)7s] %(message)s"
14
+
15
+ JSON_LOGS_ENV_VAR = "GEN3_JSON_LOGS"
16
+
17
+ _TRUTHY = frozenset({"1", "true", "t", "yes", "y", "on"})
18
+
19
+ _LOG_LEVELS = MappingProxyType(
20
+ {
21
+ "notset": logging.NOTSET,
22
+ "debug": logging.DEBUG,
23
+ "info": logging.INFO,
24
+ "warning": logging.WARNING,
25
+ "warn": logging.WARNING,
26
+ "error": logging.ERROR,
27
+ "critical": logging.CRITICAL,
28
+ }
29
+ )
30
+
31
+ _TRACE_SUFFIX_ATTRIBUTE = "gen3_trace_suffix"
32
+
33
+ _OTEL_ATTRIBUTES = (
34
+ ("trace_id", "otelTraceID"),
35
+ ("span_id", "otelSpanID"),
36
+ ("service", "otelServiceName"),
37
+ )
38
+
39
+
40
+ class TextFormatter(logging.Formatter):
41
+ """
42
+ Format records with a %-style template, appending trace context.
43
+
44
+ The trace suffix is appended only when OpenTelemetry supplied usable
45
+ correlation ids, so output is unchanged from a plain logging.Formatter
46
+ whenever no trace is recording.
47
+ """
48
+
49
+ def __init__(self, fmt: str, datefmt: str | None = None) -> None:
50
+ """
51
+ Build a formatter whose template ends with the trace suffix.
52
+
53
+ The suffix must stay a template field: format appends any traceback
54
+ and stack after the template, so this is what keeps the suffix on the
55
+ message line.
56
+
57
+ Args:
58
+ fmt (str): %-style format string.
59
+ datefmt (str | None): strftime format for asctime, or None for the
60
+ logging default.
61
+ """
62
+
63
+ super().__init__(fmt + "%(" + _TRACE_SUFFIX_ATTRIBUTE + ")s", datefmt)
64
+
65
+ def format(self, record: logging.LogRecord) -> str:
66
+ """
67
+ Render a record as text, with a trace suffix when one is available.
68
+
69
+ Args:
70
+ record (logging.LogRecord): record to format.
71
+
72
+ Returns:
73
+ str: the formatted line, followed by any traceback or stack.
74
+ """
75
+
76
+ setattr(record, _TRACE_SUFFIX_ATTRIBUTE, _trace_suffix(record))
77
+
78
+ return super().format(record)
79
+
80
+
81
+ class JsonFormatter(logging.Formatter):
82
+ """
83
+ Format log records as single-line JSON objects.
84
+
85
+ OpenTelemetry correlation fields are read off the record when present and
86
+ emitted as null otherwise, so records format correctly whether or not
87
+ opentelemetry-instrumentation-logging is installed and instrumenting.
88
+
89
+ Fields passed through a logging call's `extra=` are not emitted.
90
+ """
91
+
92
+ # gmtime pairs with the trailing Z in default_msec_format; localtime would
93
+ # label local times as UTC. staticmethod is for type checkers, which treat a
94
+ # bare callable class attribute as an unbound method and reject it as an
95
+ # incompatible override of Formatter.converter.
96
+ converter = staticmethod(time.gmtime)
97
+ default_time_format = "%Y-%m-%dT%H:%M:%S"
98
+ default_msec_format = "%s.%03dZ"
99
+
100
+ def format(self, record: logging.LogRecord) -> str:
101
+ """
102
+ Render a record as a JSON object.
103
+
104
+ Args:
105
+ record (logging.LogRecord): record to format.
106
+
107
+ Returns:
108
+ str: single-line JSON object.
109
+ """
110
+
111
+ payload = {
112
+ "timestamp": self.formatTime(record, self.datefmt),
113
+ "logger": record.name,
114
+ "level": record.levelname,
115
+ "message": record.getMessage(),
116
+ **_otel_fields(record),
117
+ }
118
+
119
+ if record.exc_info:
120
+ payload["exception"] = self.formatException(record.exc_info)
121
+ if record.stack_info:
122
+ payload["stack_info"] = self.formatStack(record.stack_info)
123
+
124
+ # default=str keeps a non-serializable value from raising inside a log call
125
+ return json.dumps(payload, default=str)
126
+
127
+
128
+ def get_stream_handler(
129
+ format: str | None = None, json_logs: bool | None = None
130
+ ) -> logging.StreamHandler[TextIO]:
131
+ """
132
+ Return a stdout stream handler
133
+
134
+ All logs will write to stdout.
135
+
136
+ Args:
137
+ format (str | None): %-style format string. Defaults to
138
+ FORMAT. Ignored when JSON is enabled.
139
+ json_logs (bool | None): emit JSON instead of text. When None, falls
140
+ back to the GEN3_JSON_LOGS env var.
141
+
142
+ Returns:
143
+ logging.StreamHandler[TextIO]: pre-formatted stream handler
144
+ """
145
+
146
+ handler = logging.StreamHandler(sys.stdout)
147
+ handler.setFormatter(_get_formatter(format, json_logs))
148
+
149
+ return handler
150
+
151
+
152
+ def get_file_handler(
153
+ file_name: str, format: str | None = None, json_logs: bool | None = None
154
+ ) -> logging.FileHandler:
155
+ """
156
+ Return a file handler
157
+
158
+ Args:
159
+ file_name (str): name of file to write logs to
160
+ format (str | None): %-style format string. Defaults to
161
+ FORMAT. Ignored when JSON is enabled.
162
+ json_logs (bool | None): emit JSON instead of text. When None, falls
163
+ back to the GEN3_JSON_LOGS env var.
164
+
165
+ Returns:
166
+ logging.FileHandler: pre-formatted file handler
167
+ """
168
+
169
+ handler = logging.FileHandler(file_name)
170
+ handler.setFormatter(_get_formatter(format, json_logs))
171
+
172
+ return handler
173
+
174
+
175
+ def get_logger(
176
+ logger_name: str | None,
177
+ file_name: str | None = None,
178
+ log_level: str | None = None,
179
+ format: str | None = None,
180
+ json_logs: bool | None = None,
181
+ ) -> logging.Logger:
182
+ """
183
+ Return an opinionated basic logger named `logger_name` that logs to stdout
184
+
185
+ If you leave the log level argument as None and the logger was not
186
+ previously instantiated, the level will be set to NOTSET. If the logger
187
+ was previously instantiated, the level will be left alone.
188
+
189
+ If the level is NOTSET, then ancestor loggers are traversed and searched
190
+ for a log_level and handler. See python docs.
191
+
192
+ If you change the log level to something other than debug (or notset) then it will not
193
+ display log statements below that level (see example below for details).
194
+ Ideally this should be handled by your application's command line args.
195
+
196
+ file_name, format and json_logs only apply when the logger gets its
197
+ handlers, which happens on the first call that sets a level other than
198
+ notset. A later call for the same logger leaves its handlers as they are,
199
+ so GEN3_JSON_LOGS is the reliable way to switch a whole service to JSON.
200
+
201
+ eg:
202
+ ```
203
+ log = get_logger('hi', log_level='info')
204
+ log.debug('hello world') # <- this will not display
205
+ ```
206
+
207
+ Args:
208
+ logger_name (str | None): name of the logger, or None for the root logger.
209
+ Python's root logger defaults to WARNING, so it
210
+ gets a handler even without a log_level, and
211
+ log_level="notset" removes every root handler,
212
+ including ones other libraries installed.
213
+ file_name (str | None): if present, will write logs to file as well
214
+ log_level (str | None): level of logging for this logger, in any case. string
215
+ so you don't have to import logging in the
216
+ application
217
+ format (str | None): %-style format string. Defaults to
218
+ FORMAT. Ignored when JSON is enabled.
219
+ json_logs (bool | None): emit JSON instead of text. When None, falls
220
+ back to the GEN3_JSON_LOGS env var.
221
+
222
+ Returns:
223
+ logging.Logger: pre-formatted logger object
224
+
225
+ Raises:
226
+ ValueError: if log_level is not one of the supported level names.
227
+ """
228
+
229
+ logger = logging.getLogger(logger_name)
230
+
231
+ if log_level:
232
+ # notset maps to 0, so a falsiness check would reject it
233
+ level = (
234
+ _LOG_LEVELS.get(log_level.lower()) if isinstance(log_level, str) else None
235
+ )
236
+ if level is None:
237
+ raise ValueError(
238
+ f"Invalid log_level parameter: {log_level}. "
239
+ f"Expected one of these strings (case-insensitive): {', '.join(_LOG_LEVELS)}"
240
+ f"(e.g. log_level='info' instead of logging.INFO)."
241
+ )
242
+
243
+ logger.setLevel(level)
244
+ # Else, NOTSET is Python default.
245
+
246
+ logger.propagate = logger.level == logging.NOTSET
247
+
248
+ if logger.level != logging.NOTSET and not logger.handlers:
249
+ logger.addHandler(get_stream_handler(format=format, json_logs=json_logs))
250
+
251
+ if file_name:
252
+ logger.addHandler(
253
+ get_file_handler(file_name, format=format, json_logs=json_logs)
254
+ )
255
+ # Else if at least one log handler exists that means it has been
256
+ # instantiated with the same name before. Do not keep creating handlers
257
+ # or your logs will be very messy.
258
+ if logger.level == logging.NOTSET:
259
+ # Delete handlers in case level was set back to NOTSET
260
+ # after being set to something else
261
+ del logger.handlers[:]
262
+
263
+ return logger
264
+
265
+
266
+ def _get_formatter(format: str | None, json_logs: bool | None) -> logging.Formatter:
267
+ """
268
+ Return the formatter for a format and JSON selection.
269
+
270
+ Args:
271
+ format (str | None): %-style format string, or None for FORMAT.
272
+ json_logs (bool | None): whether to emit JSON. None defers to the
273
+ GEN3_JSON_LOGS env var.
274
+
275
+ Returns:
276
+ logging.Formatter: JsonFormatter when JSON is enabled, otherwise a
277
+ TextFormatter over the given template.
278
+ """
279
+
280
+ if json_logs is None:
281
+ json_logs = _json_logs_enabled_in_env()
282
+
283
+ if json_logs:
284
+ return JsonFormatter()
285
+
286
+ return TextFormatter(format or FORMAT)
287
+
288
+
289
+ def _json_logs_enabled_in_env() -> bool:
290
+ """
291
+ Return whether the GEN3_JSON_LOGS env var asks for JSON output.
292
+
293
+ Returns:
294
+ bool: True when the env var holds a recognized truthy value.
295
+ """
296
+
297
+ return os.environ.get(JSON_LOGS_ENV_VAR, "").strip().lower() in _TRUTHY
298
+
299
+
300
+ def _trace_suffix(record: logging.LogRecord) -> str:
301
+ """
302
+ Build the bracketed trace suffix for a text log line.
303
+
304
+ Args:
305
+ record (logging.LogRecord): record to read correlation fields from.
306
+
307
+ Returns:
308
+ str: suffix beginning with a space, or an empty string when no trace
309
+ context is available.
310
+ """
311
+
312
+ available = [
313
+ "{}={}".format(label, value)
314
+ for label, value in _otel_fields(record).items()
315
+ if value is not None
316
+ ]
317
+
318
+ if not available:
319
+ return ""
320
+
321
+ return " [{}]".format(" ".join(available))
322
+
323
+
324
+ def _otel_fields(record: logging.LogRecord) -> dict[str, str | None]:
325
+ """
326
+ Read OpenTelemetry correlation fields off a record.
327
+
328
+ Args:
329
+ record (logging.LogRecord): record to read from.
330
+
331
+ Returns:
332
+ dict[str, str | None]: correlation field names mapped to their value,
333
+ or None when the field is unavailable.
334
+ """
335
+
336
+ return {
337
+ label: _otel_value(record, attribute) for label, attribute in _OTEL_ATTRIBUTES
338
+ }
339
+
340
+
341
+ def _otel_value(record: logging.LogRecord, attribute: str) -> str | None:
342
+ """
343
+ Read one OpenTelemetry attribute, normalizing "no trace" to None.
344
+
345
+ Args:
346
+ record (logging.LogRecord): record to read the value from.
347
+ attribute (str): name of the record attribute holding the value.
348
+
349
+ Returns:
350
+ str | None: the value, or None when no trace was recording.
351
+ """
352
+
353
+ value = getattr(record, attribute, None)
354
+
355
+ # LoggingInstrumentor writes "0" for ids when no span is recording, and an
356
+ # empty service name when unset.
357
+ if not value or (isinstance(value, str) and not value.strip("0")):
358
+ return None
359
+
360
+ return value
gen3logging/py.typed ADDED
File without changes
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: gen3logging
3
+ Version: 2.0.0
4
+ Summary: Standardized logging tool and format for Gen3
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ License-File: NOTICE
8
+ Author: CTDS UChicago
9
+ Author-email: cdis@uchicago.edu
10
+ Requires-Python: >=3.13,<4
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: System :: Logging
14
+ Project-URL: Homepage, https://github.com/uc-cdis/gen3logging
15
+ Project-URL: Repository, https://github.com/uc-cdis/gen3logging
16
+ Description-Content-Type: text/markdown
17
+
18
+ # gen3logging
19
+
20
+ Logging routines to centralize format.
21
+
22
+ ## Basic usage
23
+
24
+ ---
25
+
26
+ In the parent/root module:
27
+
28
+ ```python
29
+ from gen3logging import get_logger
30
+
31
+ logger = get_logger("{{service_name}}", log_level='info')
32
+ logger.info('Hello world!')
33
+ ```
34
+
35
+ In a child module:
36
+
37
+ ```python
38
+ from gen3logging import get_logger
39
+
40
+ logger = get_logger(__name__)
41
+ logger.info('Hello world!')
42
+
43
+ logger = get_logger(__name__, log_level='debug')
44
+ logger.debug('I am a child logger but I now have my own custom log level!')
45
+ ```
46
+
47
+ You _must_ set the logging level on the parent logger!
48
+
49
+ Inheritance is by dotted name, so the root logger's name must be a prefix of the
50
+ child module's `__name__`. Naming the root after the top-level package (a module
51
+ in `fence/auth.py` has `__name__ == "fence.auth"`, which inherits from `fence`)
52
+ is what makes this work. A root name that is not a prefix of its modules' names
53
+ gets no children.
54
+
55
+ The default `log_level` argument in `get_logger` is `None`, which means the default logging level for new loggers is `NOTSET`. This means that child loggers whose levels were not explicitly set will inherit logging levels and handlers from ancestor loggers. This makes it easier to do things like change application-wide logging levels by just setting the level on the parent logger. Levels and handlers can still be individually set on child nodes by providing a `log_level` argument.
56
+
57
+ See more about Python logging [here](https://docs.python.org/3/library/logging.html).
58
+
59
+ ## Parameters
60
+
61
+ ---
62
+
63
+ `get_logger` takes:
64
+
65
+ * `logger_name` - name of the logger, or `None` for the root logger
66
+ * `file_name` (default: `None`) - if present, the logger will output logs to a file as well as stdout
67
+ * `log_level` (default: `None`) - one of `notset`, `debug`, `info`, `warning`, `warn`, `error`, `critical`, in any case. Anything else raises `ValueError`
68
+ * `format` (default: `None`, meaning the format below) - `%`-style format string for text output
69
+ * `json_logs` (default: `None`, meaning the `GEN3_JSON_LOGS` env var decides) - emit JSON instead of text
70
+
71
+ `file_name`, `format` and `json_logs` only apply when a logger first gets its
72
+ handlers, on the first call that sets a level other than `notset`. Calling
73
+ `get_logger` again for the same logger keeps its existing handlers, so set
74
+ `GEN3_JSON_LOGS` to switch a whole service to JSON regardless of call order.
75
+
76
+ ## Output format
77
+
78
+ ---
79
+
80
+ By default logs are plain text:
81
+
82
+ ```
83
+ [2025-01-15 12:22:04,031][ fence][ INFO] user logged in
84
+ ```
85
+
86
+ When OpenTelemetry is active, trace context is appended automatically:
87
+
88
+ ```
89
+ [2025-01-15 12:22:04,031][ fence][ INFO] user logged in [trace_id=4bf92f3577b34da6a3ce929d0e0e4736 span_id=00f067aa0ba902b7 service=fence]
90
+ ```
91
+
92
+ The suffix carries only the fields that are available, and is absent entirely
93
+ when none are. It follows the message, ahead of any traceback or stack.
94
+ `gen3logging` does not depend on OpenTelemetry: populate these by
95
+ installing `opentelemetry-instrumentation-logging` and calling
96
+ `LoggingInstrumentor().instrument()`. Nothing needs to change here to pick them
97
+ up, and nothing fails when they are missing.
98
+
99
+ `trace_id` and `span_id` are either a usable id or absent.
100
+
101
+ Any `%`-style format string can replace the default:
102
+
103
+ ```python
104
+ logger = get_logger("gen3foo", log_level='info', format="%(levelname)s %(message)s")
105
+ ```
106
+
107
+ ## Enabling JSON Logs
108
+
109
+ ---
110
+
111
+ Set `json_logs=True` to emit one JSON object per line instead of the default format:
112
+
113
+ ```python
114
+ logger = get_logger("gen3foo", log_level='info', json_logs=True)
115
+ ```
116
+
117
+ ```json
118
+ {"timestamp": "2025-01-15T18:22:04.031Z", "logger": "fence.auth", "level": "INFO", "message": "user logged in", "trace_id": null, "span_id": null, "service": null}
119
+ ```
120
+
121
+ | Key | Value |
122
+ | -------------------------------- | ----------------------------------------------------------------- |
123
+ | `timestamp` | ISO 8601 UTC, millisecond precision |
124
+ | `logger` | logger name |
125
+ | `level` | level name, e.g. `INFO` |
126
+ | `message` | the formatted message, with `%`-style arguments interpolated |
127
+ | `trace_id`, `span_id`, `service` | OpenTelemetry correlation, `null` when unavailable |
128
+ | `exception` | traceback text, present only on records that carry exception info |
129
+ | `stack_info` | stack text, present only on records logged with `stack_info=True` |
130
+
131
+ Fields passed through a logging call's `extra=` are not included.
132
+
133
+ Because the message and traceback are JSON-escaped, a multi-line traceback stays
134
+ on a single log line and can be parsed by a log aggregator without stitching.
135
+
136
+ To turn JSON on for a deployment without a code change, set the
137
+ `GEN3_JSON_LOGS` environment variable:
138
+
139
+ ```
140
+ GEN3_JSON_LOGS=true
141
+ ```
142
+
143
+ An explicit `json_logs` argument always wins over the environment variable, so a
144
+ service can force either format. When `json_logs` is omitted the environment
145
+ variable decides, and when neither is set, output is text. Enabling JSON
146
+ supersedes any `format` string.
147
+
148
+ ## Migrating from `cdislogging`
149
+
150
+ ---
151
+
152
+ 1. Replace the `cdislogging` dependency with `gen3logging>=2.0.0`.
153
+ 2. Replace `from cdislogging import ...` with `from gen3logging import ...`.
154
+
155
+ That is the whole migration. Output is identical to `cdislogging` 1.2.0
156
+ until you enable JSON or instrument with OpenTelemetry.
157
+
158
+ > NOTE: The library also now contains a PEP 561 py.typed marker, which tells type checkers to enforce our typing.
159
+
@@ -0,0 +1,7 @@
1
+ gen3logging/__init__.py,sha256=6LSAqynRcqaNgSAOd9o-u0S6idIazc3ufZ2Q-fLTTZY,11709
2
+ gen3logging/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ gen3logging-2.0.0.dist-info/METADATA,sha256=lgsdttotWLfTNR37NLhVnBVc8v-_q0C0g-kOXQagaAc,6248
4
+ gen3logging-2.0.0.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
5
+ gen3logging-2.0.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
6
+ gen3logging-2.0.0.dist-info/licenses/NOTICE,sha256=l70CHeSzHxrqPdFGcLY9T0mq5pnIhyTlxQmVQhIRFuA,561
7
+ gen3logging-2.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.5.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ Copyright 2017 University of Chicago
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.