mirror of
https://github.com/kirill-markin/repo-to-text.git
synced 2025-12-05 19:12:24 -08:00
debug logging option
This commit is contained in:
parent
2dd3413f0d
commit
b3282bfc6e
3 changed files with 22 additions and 5 deletions
|
|
@ -52,6 +52,14 @@ repo-to-text
|
|||
|
||||
This will create a file named `repo_structure.txt` in the current directory with the text representation of the repository.
|
||||
|
||||
## Enabling Debug Logging
|
||||
|
||||
By default, repo-to-text runs with INFO logging level. To enable DEBUG logging, use the --debug flag:
|
||||
|
||||
```bash
|
||||
repo-to-text --debug
|
||||
```
|
||||
|
||||
## Example Output
|
||||
|
||||
The generated text file will include the directory structure and contents of each file. For example:
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@ import os
|
|||
import subprocess
|
||||
import pathspec
|
||||
import logging
|
||||
import argparse
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
def setup_logging(debug=False):
|
||||
logging_level = logging.DEBUG if debug else logging.INFO
|
||||
logging.basicConfig(level=logging_level, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
def get_tree_structure(path='.', gitignore_spec=None) -> str:
|
||||
logging.debug(f'Generating tree structure for path: {path}')
|
||||
|
|
@ -106,10 +108,15 @@ def save_repo_to_text(path='.') -> None:
|
|||
file.write('\n```\n')
|
||||
logging.debug('Repository contents written to file')
|
||||
|
||||
def main() -> None:
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Convert repository structure and contents to text')
|
||||
parser.add_argument('--debug', action='store_true', help='Enable debug logging')
|
||||
args = parser.parse_args()
|
||||
|
||||
setup_logging(debug=args.debug)
|
||||
logging.debug('repo-to-text script started')
|
||||
save_repo_to_text()
|
||||
logging.debug('repo-to-text script finished')
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.debug('repo-to-text script started')
|
||||
main()
|
||||
logging.debug('repo-to-text script finished')
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
setuptools==70.0.0
|
||||
pathspec==0.12.1
|
||||
pytest==8.2.2
|
||||
argparse==1.4.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue