Skip to content

Commit

Permalink
fix file logger example
Browse files Browse the repository at this point in the history
  • Loading branch information
thatstoasty committed Jul 24, 2024
1 parent 0aeca31 commit bebae2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 3 additions & 4 deletions examples/file_logger.mojo
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from stump import DEBUG, JSON_FORMAT, BoundLogger, PrintLogger, FileLogger
from stump import DEBUG, FileLogger, BoundLogger, json_formatter


alias LOG_LEVEL = DEBUG


fn main() raises:
var logger = BoundLogger(
FileLogger(path="/Users/mikhailtavarez/Git/mojo/stump/log.txt", level=LOG_LEVEL), formatter=JSON_FORMAT
)
var handle = open("/Users/mikhailtavarez/Git/mojo/stump/log.txt", "w")
var logger = BoundLogger(FileLogger(handle^, level=DEBUG), formatter=json_formatter, apply_styles=False)
logger.info("Information is good.", "key", "value")
logger.warn("Warnings can be good too.", "no_value")
logger.error("An error!", erroring=True)
Expand Down
6 changes: 5 additions & 1 deletion log.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
%Y-%m-%d %H:%M:%S INFO Testing print...
{"message":"Information is good.", "key":"value", "timestamp":"%Y-%m-%d %H:%M:%S", "level":"INFO"}
{"message":"Warnings can be good too.", "no_value":"", "timestamp":"%Y-%m-%d %H:%M:%S", "level":"WARN"}
{"message":"An error!", "erroring":"True", "timestamp":"%Y-%m-%d %H:%M:%S", "level":"ERROR"}
{"message":"uh oh...", "number":"4", "mojo":"🔥", "timestamp":"%Y-%m-%d %H:%M:%S", "level":"FATAL"}
{"message":"Debugging...", "timestamp":"%Y-%m-%d %H:%M:%S", "level":"DEBUG"}

0 comments on commit bebae2c

Please sign in to comment.