Skip to content

Commit

Permalink
Creating a logger in JBC
Browse files Browse the repository at this point in the history
  • Loading branch information
Marx-wrld committed Sep 7, 2023
1 parent 16d4d4a commit 373d867
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CreatingLoggerInJBC/MX.Logger.b
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$PACKAGE MX.Training
SUBROUTINE MX.Logger(data, err)

err = ''

log_file = 'test_' : OCONV(DATE(), 'DG') : '.log'
log_line = OCONV(TIME(), 'MTS') : '|' : data

OPENSEQ '../bnk.log', log_file TO file_ptr THEN NULL

WHITESEQ log_line APPEND TO file_ptr ELSE err = 'ERROR: Failed to write to ': log_file

CLOSESEQ file_ptr

RETURN
END
12 changes: 12 additions & 0 deletions CreatingLoggerInJBC/MX.TestProg.b
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PROGRAM MX.TestProg

$USING MX.Training

PROMPT 'Enter a text to log: '
INPUT text
CRT

MX.Training.Logger(text, err)
IF err NE '' THEN CRT err ELSE CRT 'OK'

END

0 comments on commit 373d867

Please sign in to comment.