Skip to content

Commit

Permalink
log multi line
Browse files Browse the repository at this point in the history
  • Loading branch information
srosam committed Feb 3, 2023
1 parent f984d78 commit 7e2a276
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import os
import requests # noqa We are just importing this to prove the dependency installed correctly

messages = []

def main():
def send_log():
env_file = os.getenv('GITHUB_ENV')

with open(env_file, "a") as myfile:
myfile.write("MY_VAR=MY_VALUE")
message = "\n".join(messages)

with open(env_file, "a") as myfile:
myfile.write("\nMY_VAR=MY_VALUE2")
myfile.write(f"MY_VAR={message}")

def log_message(message):
messages.append(message)


def main():
try:
log_message("foo")
log_message("bar")
log_message("baz")
except Exception as e:
log_message("Error")
finally:
send_log()


if __name__ == "__main__":
Expand Down

0 comments on commit 7e2a276

Please sign in to comment.