Jump to content

[SOLVED] why won't this simple Logger work?


Recommended Posts

this is my code :

============= FILE : logging.au3 ===========
 
#Include <Date.au3>
 
 
func LogMsg($msg)
    $fileName = "log.txt"
    $file = FileOpen($fileName, 1)
    if $file = -1 Then
        MsgBox(0, "Error", "could not open file " & $fileName)
        Exit
    EndIf
    
    FileWriteLine($file, _Date_Time_GetSystemTime() & " : " & $msg)
    FileFlush ($file)
    FileClose($file)        
    
endFunc
 
============= FILE: mytest.au3 =============
 
#include "logging.au3"
 
LogMsg("this is a test")

As you can see it's very basic and very straightforward.

Yet, after I execute "mytest.au3" in SciTE, the file "log.txt" exists but remains desperately empty...

I'm on Windows 7 with a Symantec antivirus

Edited by MonsieurOUXX
Link to comment
Share on other sites

#include <GuiConstantsEx.au3>
#include <Date.au3>
#include <WindowsConstants.au3>

 LogMsg("this is a test")

func LogMsg($msg)
    $fileName = "log.txt"
    $file = FileOpen($fileName, 1)
    if $file = -1 Then
        MsgBox(0, "Error", "could not open file " & $fileName)
        Exit
    EndIf
    $tDate = _Date_Time_GetSystemTime()
    FileWriteLine($file, _Date_Time_SystemTimeToDateStr($tDate) & " : " & $msg)
    FileFlush ($file)
    FileClose($file)

endFunc

Edited by sleepydvdr

#include <ByteMe.au3>

Link to comment
Share on other sites

Sorry about posting to the wrong forum! I'm pretty much new around here ( I was around some time ago but since then I lost all my good habits :graduated: ). My apologies again.

And both of you are absolutely right: I added "_Date_Time_GetSystemTime()" in a rush at the very end and trusted the name without checking the specs. I was so focused on the file management that I forgot to double-check that, thinking "oh, whatever it outputs I'll have time later to correct it and format it better". Shame on me!

Thank you so much, guys/ladies.

EDIT: Actually it doesn't change anything, the problem remains....

Edited by MonsieurOUXX
Link to comment
Share on other sites

BUMP.

Even with that change, the file remains empty...

EDIT :

OH WAIT that's actually hilarious (well, from my perspective it is).

The issue was simply that since my early tests there were hundreds of blank lines at the beginning of the file.

All I had to do was... to scroll down. :graduated:

And if you think I'm retarded, well have a look at Windows 7's theme, where everything is pale gray and where nothing catches the eye (ninja scrollbars...)

Edited by MonsieurOUXX
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...