Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,27 @@ def example_31():
raise CraftError("Error 1\nError 2")


def example_32():
"""Logger affects emitter."""
logger = logging.getLogger()
# This doesn't work (streaming_brief=True)
emit.init(EmitterMode.BRIEF, "explorator", "Greetings earthlings", streaming_brief=True)
# This works
# emit.init(EmitterMode.BRIEF, "explorator", "Greetings earthlings")
logger.setLevel(logging.DEBUG)

# it only fails if following message contains whitespace characters inside string
logger.info("Message from external logger 2")

# examples of failing cases
# emit.progress("Final\tmessage")
emit.message("Final message\nMultiline")

# but those would work
# emit.message("Single message")
# emit.progress("Final message\n")


# -- end of test cases

if len(sys.argv) < 2:
Expand All @@ -534,7 +555,7 @@ def example_31():
print(f"ERROR: function {name!r} not found")
exit()

if int(sys.argv[1]) != 29:
if int(sys.argv[1]) not in (29, 32):
emit.init(EmitterMode.BRIEF, "explorator", "Greetings earthlings")
try:
func(*sys.argv[2:])
Expand Down
Loading