ID:2109651
 
Resolved
Setting world.log to a subdirectory that didn't exist wouldn't create that directory.
BYOND Version:510.1346
Operating System:Linux
Web Browser:Chrome 51.0.2704.103
Applies to:Dream Daemon
Status: Resolved (513.1503)

This issue has been resolved.
Descriptive Problem Summary:
Assigning eg file("foo/bar.txt") to world.log then writing to world.log will not create 'foo/bar.txt' if the folder 'foo' does not already exist.

Numbered Steps to Reproduce Problem:
1. Assign world.log to file("folder/file.txt") where 'folder' does not exist
2. Write to world.log via <<
3. Observe lack of 'folder/file.txt'

Code Snippet (if applicable) to Reproduce Problem:
/world/New()
log = file("foo/bar.txt") // folder 'foo' does not exist
log << "bar" // does *not* create 'foo/bar.txt'

// If you write before assigning, the file is created correctly,
// and future output to world.log is written as expected:
var/new_log = file("bar/foo.txt")
new_log << "something"
log = new_log
log << "foo" // written to 'bar/foo.txt'


Expected Results:
Assigning a file in a non-existent folder to world.log then writing to it would create the folder.

Actual Results:
It did not create the folder or write to file.

Does the problem occur:
Every time? Or how often? Every time.
In other games? Yes.
In other user accounts? Yes.
On other computers? Yes.

When does the problem NOT occur? When you write to the file prior to assigning it to world.log

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? Unknown

Workarounds: Write to the file before assigning it to world.log

Descriptive Problem Summary:

world.log can't create new directories, only write to existing ones.

Numbered Steps to Reproduce Problem:

1) Set world.log to something like "logs/log.txt"
2) Make sure the "logs" directory doesn't exit.
3) Find that world.log acts as if it's not set to a file.
4) Create the "logs" directory.
5) Find the world.log works as expected.

Code Snippet (if applicable) to Reproduce Problem:
world.log = "logs/log.txt"


Expected Results:

It to create the "logs" directory like every other file I/O operation does.

Actual Results:

world.log outputs to O&M (and the default output control) as if it's not pointing at a valid file. No file is created.

Does the problem occur:
Every time? Or how often? Every time.
In other games? Assume so
In other user accounts? Yes
On other computers? Yes

When does the problem NOT occur?

When creating the directory before writing to world.log.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)

I'm pretty sure it would have been reported already if it was happening in older versions, but I can't really test it.

Workarounds:

Use text2file() to write to world.log first.

text2file("Beginning log",world.log)
Descriptive Problem Summary:

When setting world.log to a value with folders, if those folders don't already exist it won't create the file. If the folders exist, things work as expected.

Numbered Steps to Reproduce Problem:

1) Set world.log to "one/logs.txt"
2) Don't have a "one" folder.
3) Don't get any world.log output.

Code Snippet (if applicable) to Reproduce Problem:
world/New()
log = "one/logs.txt"
..()


Expected Results:

It to create the folders it needs like every other file operation BYOND does.

Actual Results:

Nothing. Nothing at all, no logging, no errors, nada. Everything will be dumped into Options and Messages as if you didn't set world.log at all.

Does the problem occur:
Every time? Or how often? Every time.
In other games? Yes
In other user accounts? Yes
On other computers? Yes

When does the problem NOT occur?

When you create the directories beforehand.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)

Actually think this has been happening for as long as I remember.

Workarounds:

Create directories and defeat the purpose of automated code.
In response to Nadrew
Lummox JR resolved issue with message:
Setting world.log to a subdirectory that didn't exist wouldn't create that directory.