summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--src/pyssg/__init__.py4
-rw-r--r--src/pyssg/arg_parser.py3
-rw-r--r--src/pyssg/pyssg.py14
4 files changed, 17 insertions, 6 deletions
diff --git a/README.md b/README.md
index 2163a95..722ada4 100644
--- a/README.md
+++ b/README.md
@@ -57,7 +57,7 @@ Will add a PKBUILD (and possibly submit it to the AUR) sometime later.
pyssg --copy-default-config -c <path/to/config>
```
-Where `-c` is optional as by default `$XDG_CONFIG_HOME/pyssg/config.ini` is used.
+- Where `-c` is optional as by default `$XDG_CONFIG_HOME/pyssg/config.ini` is used.
2. Edit the config file created as needed.
diff --git a/src/pyssg/__init__.py b/src/pyssg/__init__.py
index cdd4cd1..3bbfc27 100644
--- a/src/pyssg/__init__.py
+++ b/src/pyssg/__init__.py
@@ -4,9 +4,7 @@ from logging import Logger, StreamHandler
from .per_level_formatter import PerLevelFormatter
-# since this is the root package, setup the logger here,
-# set DEBUG here for testing purposes, can't make it
-# dynamic yet (with a flag, for example)
+# since this is the root package, setup the logger here
__LOG_LEVEL: int = logging.INFO
log: Logger = logging.getLogger(__name__)
log.setLevel(__LOG_LEVEL)
diff --git a/src/pyssg/arg_parser.py b/src/pyssg/arg_parser.py
index 90fb8c1..ec150fb 100644
--- a/src/pyssg/arg_parser.py
+++ b/src/pyssg/arg_parser.py
@@ -34,6 +34,9 @@ def get_parsed_arguments() -> Namespace:
action='store_true',
help='''force building all pages and not only the
updated ones''')
+ parser.add_argument('--debug',
+ action='store_true',
+ help='''change logging level from info to debug''')
# really not needed, too much bloat and case scenarios to check for,
# instead, just read from config file or default config file
"""
diff --git a/src/pyssg/pyssg.py b/src/pyssg/pyssg.py
index 958b397..2844fbf 100644
--- a/src/pyssg/pyssg.py
+++ b/src/pyssg/pyssg.py
@@ -25,7 +25,17 @@ log: Logger = logging.getLogger(__name__)
def main() -> None:
args: dict[str, Union[str, bool]] = vars(get_parsed_arguments())
- if not len(sys.argv) > 1:
+ if args['debug']:
+ # need to modify the root logger specifically,
+ # as it is the one that holds the config
+ # (__name__ happens to resolve to pyssg in __init__)
+ root_logger: Logger = logging.getLogger('pyssg')
+ root_logger.setLevel(logging.DEBUG)
+ for handler in root_logger.handlers:
+ handler.setLevel(logging.DEBUG)
+ log.debug('changed logging level to DEBUG')
+
+ if not len(sys.argv) > 1 or (len(sys.argv) == 2 and args['debug']):
log.info('pyssg v%s - no arguments passed, --help for more', VERSION)
sys.exit(0)
@@ -77,7 +87,7 @@ def main() -> None:
# TODO: add logging to all of the build part, that includes the builder,
# database, discovery, page and parser
if args['build']:
- # start the db
+ log.debug('building the html files')
db: Database = Database(os.path.join(config.get('path', 'src'), '.files'))
db.read()