44from rich .style import Style
55from rich .tree import Tree
66
7+ import plain2code_logger
8+
79CHARACTERS_TO_TOKENS_RULE_OF_THUMB_RATIO = 4
810
11+ logger = logging .getLogger (plain2code_logger .LOGGER_NAME )
12+
913
1014class Plain2CodeConsole (Console ):
1115 INFO_STYLE = Style ()
@@ -22,35 +26,35 @@ def __init__(self):
2226
2327 self .llm_encoding = tiktoken .get_encoding ("cl100k_base" )
2428 except Exception as e :
25- logging .warning (
29+ logger .warning (
2630 "Failed to import optional library tiktoken. Using approximate instead of exact token count."
2731 )
28- logging .debug (f"Exception: { e } " )
32+ logger .debug (f"Exception: { e } " )
2933 self .llm_encoding = None
3034
3135 def info (self , * args , ** kwargs ):
32- logging .info (" " .join (map (str , args )))
36+ logger .info (" " .join (map (str , args )))
3337 super ().print (* args , ** kwargs , style = self .INFO_STYLE )
3438
3539 def warning (self , * args , ** kwargs ):
36- logging .warning (" " .join (map (str , args )))
40+ logger .warning (" " .join (map (str , args )))
3741 super ().print (* args , ** kwargs , style = self .WARNING_STYLE )
3842
3943 def error (self , * args , ** kwargs ):
40- logging .error (" " .join (map (str , args )))
44+ logger .error (" " .join (map (str , args )))
4145 super ().print (* args , ** kwargs , style = self .ERROR_STYLE )
4246
4347 def input (self , * args , ** kwargs ):
4448 # We also log input as info so it shows in the toggled view
45- logging .info (" " .join (map (str , args )))
49+ logger .info (" " .join (map (str , args )))
4650 super ().print (* args , ** kwargs , style = self .INPUT_STYLE )
4751
4852 def output (self , * args , ** kwargs ):
49- logging .info (" " .join (map (str , args )))
53+ logger .info (" " .join (map (str , args )))
5054 super ().print (* args , ** kwargs , style = self .OUTPUT_STYLE )
5155
5256 def debug (self , * args , ** kwargs ):
53- logging .debug (" " .join (map (str , args )))
57+ logger .debug (" " .join (map (str , args )))
5458 super ().print (* args , ** kwargs , style = self .DEBUG_STYLE )
5559
5660 def print_list (self , items , style = None ):
@@ -116,7 +120,7 @@ def _count_tokens(self, text):
116120
117121 def print_resources (self , resources_list , linked_resources ):
118122 if len (resources_list ) == 0 :
119- self .input ("Linked resources: None" )
123+ self .debug ("Linked resources: None" )
120124 return
121125
122126 self .input ("Linked resources:" )
0 commit comments