| closed[SOLVED] using dynamic name on log_to_file |
| Started by Tank on 07-30-2010, 03:36 PM |
Threads: 59
Joined: Jan 2007
Im working on a plugin which logs information to a file. Now it logs to a file like:rnrnlog_to_file("test.log","i am a test line")rnrnIs it possible to add a dynamic date to the name of the file? For example like you see with the amxx and server logs? I've been trying to find some plugins which do that but the plugins I found just use log_amx. Thanks in advanced.rnrnEDIT: Ok, I think I am on the right path....rnrn
rn new currentdate[7]rn new Y,m,jrn get_time("%Y%m%j",currentdate,6)rn rn log_to_file("%stest.log",currentdate,"i am a test line")rnrnIt posts the log file as: %stest.logThreads: 75
Joined: Nov 2007
Tank i dont even have the compiler on this PC. But does this script help ya? I think it will..rnrnElse write again..rnrnrn- Cheers
Threads: 75
Joined: Nov 2007
What the hell is this for ???rnrn
new Y,m,jrnrn(you dont have to answer :D )Threads: 59
Joined: Jan 2007
Thanks for posting up that plugin. Im sorry to say that that plugin didn't really help me on the log_to_file part, prolly lack of knowledge on my side. Thanks anyways. At the moment the problem is solved thanks to Synthetic.nnThe plugin did provide me with other usefull information. I was always interested to see how a SQL was hooked through a plugin. Something I've been trying for a while, so Im gonna see how it goes with the plugin next to mine.nnFor the people interested in what the code looks like when it does should work (havent tested it yet, not home for the weekend).nn
nnew currentdate[32]nget_time("%Y%m%j",currentdate,31)nadd(currentdate,31,"test.log" )nlog_to_file(currentdate,"%s","test line")nnnnnew Y,m,j nnnSince you ask this question I assume this is quite the noob-mistake. I put it there because when I tried to compile my plugin I received a compiling error saying that y,m and j were unknown something something, so I added that and the compiling error went away. Ok, the dynamic log name part not working of course, but that is the reason. Let's keep it at that I havent been fiddling around with plugins for a while :DThreads: 75
Joined: Nov 2007
hehe btw log_to_file(.., .., ..) makes a time stamp by default when you run it. The code above will make the file name %Y%m%jtest.log . But i guess you found out already =) If you get weird long lines use trim(...) before using the array. But i think its only a windows thingy =)nnThe SQL stuff isnt that hard to get running, that code should help you alot. Notice the do_Connection stock, use the same method if you dont want you server to hang. It just tests the connection before running the query, if you dont do so, and just fire the query and u dont have the connection right, your server will take a break =)

