Skip to content

Commit 54c890c

Browse files
authored
Merge pull request #170 from fcolecumberri/patch-1
use_stdout to print into stdout
2 parents 97e4eaa + decbf36 commit 54c890c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

icecream/icecream.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ def colorizedStderrPrint(s: str) -> None:
8585
stderrPrint(colored)
8686

8787

88+
89+
def colorizedStdoutPrint(s):
90+
colored = colorize(s)
91+
with supportTerminalColorsInWindows():
92+
print(colored)
93+
94+
8895
def safe_pformat(obj: object, *args: Any, **kwargs: Any) -> str:
8996
try:
9097
return pprint.pformat(obj, *args, **kwargs)
@@ -372,6 +379,12 @@ def enable(self) -> None:
372379
def disable(self) -> None:
373380
self.enabled = False
374381

382+
def use_stdout():
383+
self.outputFunction = colorizedStdoutPrint
384+
385+
def use_stderr():
386+
self.outputFunction = colorizedStderrPrint
387+
375388
def configureOutput(self: "IceCreamDebugger", prefix: Union[str, Literal[Sentinel.absent]] = Sentinel.absent, outputFunction: Union[Callable, Literal[Sentinel.absent]] =Sentinel.absent,
376389
argToStringFunction: Union[Callable, Literal[Sentinel.absent]]=Sentinel.absent, includeContext: Union[bool, Literal[Sentinel.absent]]=Sentinel.absent, contextAbsPath: Union[bool, Literal[Sentinel.absent]]=Sentinel.absent, lineWrapWidth: Union[bool, Literal[Sentinel.absent]]=Sentinel.absent) -> None:
377390
noParameterProvided = all(

0 commit comments

Comments
 (0)