Skip to content

Commit

Permalink
Merge branch 'feature-logging' into v0.1.0-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jwlodek committed Apr 2, 2020
2 parents 7d46e54 + b20fcae commit 266f80a
Show file tree
Hide file tree
Showing 48 changed files with 6,095 additions and 3,447 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_docs_test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Doc Build Test
name: build docs

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/py_cui_test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This workflow will install Python dependencies, run tests and lint for several python version on push and pull request

name: Automated Unit Testing
name: Tests

on: [push, pull_request]

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ markdoc/
npdoc2md/
*.*~
ecui/
.coverage
py_cui_log.txt
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In some extreme cases there may be exceptions to this, but in general I would li

#### Make sure the unit tests pass

If you make a pull request and Travis tells you a unit test failed, please fix the issue and append to the pull request. I will most likely only look closely at pull requests that don't show any issues with the CI. Note that if your changes edit existing functions, you may need to edit the test itself to reflect them. If you are adding a new feature, please add unit tests and confirm they pass as well.
If you make a pull request and the CI tells you a unit test failed, please fix the issue and append to the pull request. I will most likely only look closely at pull requests that don't show any issues with the CI. Note that if your changes edit existing functions, you may need to edit the test itself to reflect them. If you are adding a new feature, please add unit tests and confirm they pass as well.

#### Use consistent numpy documentation

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2019, Jakub Wlodek
Copyright (c) 2019-2020, Jakub Wlodek
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ Project | Description

BSD 3-Clause License

Copyright (c) 2019, Jakub Wlodek
Copyright (c) 2019-2020, Jakub Wlodek
File renamed without changes.
22 changes: 11 additions & 11 deletions docs/DocstringGenerated/Colors.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ Class representing a text color rendering rule

Method | Doc
-----|-----
check_match | Checks if the color rule matches a line
generate_fragments_regex | Splits text into fragments based on regular expression
split_text_on_region | Splits text into fragments based on region
_check_match | Checks if the color rule matches a line
_generate_fragments_regex | Splits text into fragments based on regular expression
_split_text_on_region | Splits text into fragments based on region
generate_fragments | Splits text into fragments if matched line to regex


Expand All @@ -53,7 +53,7 @@ Class representing a text color rendering rule
### __init__

```python
def __init__(self, regex, color, rule_type, match_type, region, include_whitespace)
def __init__(self, regex, color, rule_type, match_type, region, include_whitespace, logger)
```

Constructor for ColorRule object
Expand All @@ -76,10 +76,10 @@ Constructor for ColorRule object



### check_match
### _check_match

```python
def check_match(self, line)
def _check_match(self, line)
```

Checks if the color rule matches a line
Expand All @@ -103,10 +103,10 @@ Checks if the color rule matches a line



### generate_fragments_regex
### _generate_fragments_regex

```python
def generate_fragments_regex(self, widget, render_text)
def _generate_fragments_regex(self, widget, render_text)
```

Splits text into fragments based on regular expression
Expand All @@ -131,10 +131,10 @@ Splits text into fragments based on regular expression



### split_text_on_region
### _split_text_on_region

```python
def split_text_on_region(self, widget, render_text)
def _split_text_on_region(self, widget, render_text)
```

Splits text into fragments based on region
Expand Down Expand Up @@ -182,7 +182,7 @@ Splits text into fragments if matched line to regex

Return Variable | Type | Doc
-----|----------|-----
fragments | list of lists of [str, color] | the render text split into fragments of strings paired with colors
fragments | List[List[str, color]] | the render text split into fragments of strings paired with colors
matched | bool | Boolean output saying if a match was found in the line.


Expand Down
264 changes: 264 additions & 0 deletions docs/DocstringGenerated/Debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
# debug

Module containing py_cui logging utilities



#### Classes

Class | Doc
-----|-----
PyCUILogger(logging.Logger) | Custom logger class for py_cui, extends the base logging.Logger Class

#### Functions

Function | Doc
-----|-----
_enable_logging | Function that creates basic logging configuration for selected logger
_initialize_logger | Function that retrieves an instance of either the default or custom py_cui logger.




### _enable_logging

```python
def _enable_logging(logger, filename='py_cui_log.txt', logging_level=logging.DEBUG)
```

Function that creates basic logging configuration for selected logger




#### Parameters

Parameter | Type | Doc
-----|----------|-----
logger | PyCUILogger | Main logger object
filename | os.Pathlike | File path for output logfile
logging_level | logging.LEVEL, optional | Level of messages to display, by default logging.DEBUG

#### Raises

Error | Type | Doc
-----|----------|-----
Unknown | PermissionError | py_cui logs require permission to cwd to operate.
Unknown | TypeError | Only the custom PyCUILogger can be used here.





### _initialize_logger

```python
def _initialize_logger(py_cui_root, name=None, custom_logger=True)
```

Function that retrieves an instance of either the default or custom py_cui logger.




#### Parameters

Parameter | Type | Doc
-----|----------|-----
py_cui_root | py_cui.PyCUI | reference to the root py_cui window
name | str, optional | The name of the logger, by default None
custom_logger | bool, optional | Use a custom py_cui logger, by default True

#### Returns

Return Variable | Type | Doc
-----|----------|-----
logger | py_cui.debug.PyCUILogger | A custom logger that allows for live debugging





## PyCUILogger(logging.Logger)

```python
class PyCUILogger(logging.Logger)
```

Custom logger class for py_cui, extends the base logging.Logger Class




#### Attributes

Attribute | Type | Doc
-----|----------|-----
py_cui_root | py_cui.PyCUI | The root py_cui program for which the logger runs
live_debug | bool | Flag to toggle live debugging messages

#### Methods

Method | Doc
-----|-----
_assign_root_window | Attaches logger to the root window for live debugging
_get_debug_text | Function that generates full debug text for the log
info | Adds stacktrace info to log
debug | Function that allows for live debugging of py_cui programs by displaying log messages in the satus bar
warn | Function that allows for live debugging of py_cui programs by displaying log messages in the satus bar
error | Function that displays error messages live in status bar for py_cui logging
toggle_live_debug | Toggles live debugging mode




### __init__

```python
def __init__(self, name)
```

Initializer for the PyCUILogger helper class




#### Raises

Error | Type | Doc
-----|----------|-----
Unknown | TypeError | If root variable instance is not a PyCUI object raise a typeerror





### _assign_root_window

```python
def _assign_root_window(self, py_cui_root)
```

Attaches logger to the root window for live debugging







### _get_debug_text

```python
def _get_debug_text(self, text)
```

Function that generates full debug text for the log







### info

```python
def info(self, text)
```

Adds stacktrace info to log




#### Parameters

Parameter | Type | Doc
-----|----------|-----
text | str | The log text ot display





### debug

```python
def debug(self, text)
```

Function that allows for live debugging of py_cui programs by displaying log messages in the satus bar




#### Parameters

Parameter | Type | Doc
-----|----------|-----
text | str | The log text ot display





### warn

```python
def warn(self, text)
```

Function that allows for live debugging of py_cui programs by displaying log messages in the satus bar




#### Parameters

Parameter | Type | Doc
-----|----------|-----
text | str | The log text ot display





### error

```python
def error(self, text)
```

Function that displays error messages live in status bar for py_cui logging




#### Parameters

Parameter | Type | Doc
-----|----------|-----
text | str | The log text ot display





### toggle_live_debug

```python
def toggle_live_debug(self, level=logging.ERROR)
```

Toggles live debugging mode










Loading

0 comments on commit 266f80a

Please sign in to comment.