Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Tips and tricks
➜ Create a log file if it doesn't already exist
|
Create a log file if it doesn't already exist
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Sean Randall
United Kingdom (14 posts) Bio
|
| Date
| Sat 20 Sep 2008 08:24 PM (UTC) |
| Message
| Hello,
I've never needed to log my output before but now find myself in the position of requiring dated text files.
I have set up the world configuration logging dialog to my needs, but I get an error like this on connection...
'Could not open log file "logs\Sep 2008\Saturday 20.txt".'
Obviously the problem is that neither the folder nor file exist. Logs does, but that's about it. I should have foreseen this one - I'm just so used to everything from IRC clients to IM software creating the folders and files for you!
Does anybody have any tips on what I can do? obviously it'd be easy enough to make each file manually as I go along: is there something I can add to worldOpen to make them for me? or am I making it more difficult than it needs to be and missing something obvious?
Sean. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Sat 20 Sep 2008 09:18 PM (UTC) |
| Message
| It will create the file for you, naturally, but it won't create folders. You could script folder creation with os.execute in Lua, but probably the simplest is to make it unnecessary. Just create a file called:
"logs\Sep 2008_Saturday 20.txt"
Later on, if you wanted to (ie. each month) you could move batches of files into their own folders, based on the first part of the file name. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Sean Randall
United Kingdom (14 posts) Bio
|
| Date
| Reply #2 on Sat 20 Sep 2008 11:07 PM (UTC) |
| Message
| Thank you for that.
I almost started to think "oh, I need to CHMOD this folder first". Too much PHP on the brain for me. i'll do it that way, though; with a script to move them monthly. I haven't seen the note anywhere that it'll make files but not folders, good to know!
Thanks. Again!
Sean. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Sat 20 Sep 2008 11:42 PM (UTC) |
| Message
| If you are using auto-logging you are probably best off using %Lfilename, because if you change your current directory (eg. by browsing) the logs might not end up where you expect. (Click on the ? button - %L is the log file directory, including the trailing backslash).
I just tried to save a file in notepad where I added a non-existent directory to the start of the filename - it gave an error "path does not exist" which is the same behaviour as MUSHclient. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
17,417 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top