How would you keep a log of everything that is displayed in the output window without having to go back and find all world << instances and adding something after it to add to a log file?
It should work even when there are no players present.
Aug 1 2014, 5:27 pm
|
|
You could... winget() the text from the output, but I really don't recommend that -- probably best to do what you said and append the code to log things manually.
|
You can easily do this. BYOND makes logging very easy.
All you need is a logChat(message) proc and use it wherever output is created that you want to log. #define CHAT_LOG "chatlog.txt" |
In response to Zecronious
|
|
Zecronious wrote:
You can easily do this. BYOND makes logging very easy. > #define CHAT_LOG "chatlog.txt" This is exactly what I did "not" want to do. |
In response to Nadrew
|
|
Nadrew wrote:
You could... winget() the text from the output, but I really don't recommend that -- probably best to do what you said and append the code to log things manually. I was hoping I wouldn't have to. I was thinking about wingetting the text and if it's different than the previous text, append the last line. But, that'd be inefficient since you'll be checking for winget multiple times. :/ I guess there's no being lazy this time. |
In response to Xirre
|
|
Using world << "text" is foolish for two reasons.
1. It's hard to log. 2. It sends messages to things that can't utilize the message. Instead using the code I posted edited to be better you only ever need to write logChat() once. ONCE. From this point on stop using world << "text" and start using chat("text"). Do the smart guy thing :) #define CHAT_LOG "chatlog.txt" |
Just for reference, using "world <<" doesn't actually output to things that would never be able to utilize said output (non-clients), the << output operator is smart enough to handle that. It's actually faster to use "world <<" than it is to use "view() <<" and the sort due to the lack of intensive calculations being done. However, the idea of not using it is absolutely correct, getting rid of it allows you finer control over how things get outputted.
You can remove the need to loop entirely by keeping a list of clients and using << to output to that. var/list/clients = list() You also don't really need to output to client.mob, outputting to the client itself does the same thing without having to access their mob at all. |
Why keep a list of clients when BYOND internally keeps a list and loops through that?
Seems like the same thing. When you output to a list you're just hiding the fact that you're really doing a loop through that list anyway. Yeah if client << message works then that's better. |
It's not actually looping over the list, at least not in the way you are -- remember, any time you can use an internal method of doing something you should do it, it'll almost always work better than a soft-coded version of the same thing.
|