March 05, 2021, 07:38:18 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Like stats
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Miscellaneous
»
[bmx] AppLog Module by JoshK [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bmx] AppLog Module by JoshK [ 1+ years ago ] (Read 436 times)
BlitzBot
Jr. Member
Posts: 1
Total likes: 0
[bmx] AppLog Module by JoshK [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:41 AM »
Title :
AppLog Module
Author :
JoshK
Posted :
1+ years ago
Description :
Log messages will be written to the stdout (same as Print() ). A .log file by the same name as your application will also be automatically written.
Instead of commenting out a bunch of Print() commands, you can just enable/disable logging with AppLogMode(). An optional callback can be specified to be called for every logged string. This allows you to send the output to a console window for your application. For example, my callback function writes the string to a textarea gadget the user can view.
Code :
Code: BlitzMax
Module
leadwerks.applog
Import
brl.standardio
Import
brl.filesystem
Import
brl.system
Strict
Private
Global
AppLogEnabled
Global
AppLogStream:TStream
Global
AppLogCallback
(
text$
)
Public
Rem
bbdoc:
EndRem
Function
AppLogMode
(
mode,callback:
Byte
Ptr
=
Null
)
If
Not
mode AppLog
"Logging stopped"
AppLogEnabled=mode
AppLogCallback=callback
If
mode AppLog
"Logging started"
EndFunction
'Flags:
'1 - Error
'2 - Don't return line
'4 - Notification box
Rem
bbdoc:
EndRem
Function
AppLog
(
text$,flags=
0
)
If
Not
AppLogEnabled
Return
If
Not
AppLogStream AppLogStream=WriteFile
(
StripExt
(
AppFile
)
+
".log"
)
If
(
4
& flags
)
Notify text,
(
1
& flags
)
If
(
1
& flags
)
text=
"Error: "
+text
If
Not
(
2
& flags
)
text:+
Chr
(
13
)
+
Chr
(
10
)
If
AppLogStream AppLogStream.WriteString text
WriteStdout
text
If
AppLogCallback<>
Null
AppLogCallback
(
text
)
EndFunction
Comments :
none...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Miscellaneous
»
[bmx] AppLog Module by JoshK [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal