55from filesender .api import FileSenderClient
66from typer import Typer , Option , Argument , Context , Exit
77from rich import print
8+ from rich .pretty import pretty_repr
89from pathlib import Path
910from filesender .auth import Auth , UserAuth , GuestAuth
1011from filesender .config import get_defaults
1112from functools import wraps
1213from asyncio import run
1314from importlib .metadata import version
1415from rich .logging import RichHandler
15- from filesender .log import LogParam , LogLevel
16+ from filesender .log import LogParam , LogLevel , configure_extra_levels
1617
1718logger = logging .getLogger (__name__ )
1819
@@ -51,21 +52,21 @@ def common_args(
5152 base_url : Annotated [str , Option (help = "The URL of the FileSender REST API" )],
5253 log_level : Annotated [
5354 int , Option (click_type = LogParam (), help = "Logging verbosity" , )
54- ] = LogLevel .INFO .value ,
55+ ] = LogLevel .FEEDBACK .value ,
5556 version : Annotated [
5657 Optional [bool ], Option ("--version" , callback = version_callback )
5758 ] = None
5859):
5960 context .obj = {
6061 "base_url" : base_url
6162 }
63+ configure_extra_levels ()
6264 logging .basicConfig (
6365 level = log_level ,
6466 format = "%(message)s" ,
6567 datefmt = "[%X]" ,
6668 handlers = [RichHandler ()]
6769 )
68- logging .addLevelName (LogLevel .VERBOSE .value , 'VERBOSE' )
6970
7071
7172@app .command (context_settings = context )
@@ -114,8 +115,8 @@ def invite(
114115 }
115116 }
116117 }))
117- logger .log (LogLevel .VERBOSE .value , result )
118- logger .info ( "Invitation successfully sent" )
118+ logger .log (LogLevel .VERBOSE .value , pretty_repr ( result ) )
119+ logger .log ( LogLevel . FEEDBACK . value , "Invitation successfully sent" )
119120
120121@app .command (context_settings = context )
121122@typer_async
@@ -142,8 +143,8 @@ async def upload_voucher(
142143 await auth .prepare (client .http_client )
143144 await client .prepare ()
144145 result : Transfer = await client .upload_workflow (files , {"from" : email , "recipients" : []})
145- logger .log (LogLevel .VERBOSE .value , result )
146- logger .log (LogLevel .INFO .value , "Upload completed successfully" )
146+ logger .log (LogLevel .VERBOSE .value , pretty_repr ( result ) )
147+ logger .log (LogLevel .FEEDBACK .value , "Upload completed successfully" )
147148
148149@app .command (context_settings = context )
149150@typer_async
@@ -174,8 +175,8 @@ async def upload(
174175 )
175176 await client .prepare ()
176177 result : Transfer = await client .upload_workflow (files , {"recipients" : recipients , "from" : username })
177- logger .log (LogLevel .VERBOSE .value , result )
178- logger .log (LogLevel .INFO .value , "Upload completed successfully" )
178+ logger .log (LogLevel .VERBOSE .value , pretty_repr ( result ) )
179+ logger .log (LogLevel .FEEDBACK .value , "Upload completed successfully" )
179180
180181@app .command (context_settings = context )
181182def download (
@@ -192,7 +193,7 @@ def download(
192193 token = token ,
193194 out_dir = out_dir
194195 ))
195- logger .log (LogLevel .INFO .value , f"Download completed successfully. Files can be found in { out_dir } " )
196+ logger .log (LogLevel .FEEDBACK .value , f"Download completed successfully. Files can be found in { out_dir } " )
196197
197198@app .command (context_settings = context )
198199@typer_async
@@ -202,7 +203,7 @@ async def server_info(
202203 """Prints out information about the FileSender server you are interfacing with"""
203204 client = FileSenderClient (base_url = context .obj ["base_url" ])
204205 result = await client .get_server_info ()
205- logger .log (LogLevel .INFO .value , result )
206+ logger .log (LogLevel .FEEDBACK .value , pretty_repr ( result ) )
206207
207208if __name__ == "__main__" :
208209 app ()
0 commit comments