Raised This Month: $ Target: $400
 0% 

log_to_file vs log_amx


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SilverSquirrl
New Member
Join Date: Aug 2005
Old 08-26-2005 , 14:01   log_to_file vs log_amx
Reply With Quote #1

Ok, I'm trying to write to a log file. I have sucessfully done that that using the following code:

Code:
log_to_file("admin_bans.txt","%s TempBanned %s<%d> for %s minutes Due to: %s",name,name2,userid2,minutes,reason) and log_to_file("Bans/admin_bans.txt","%s TempBanned %s<%d> for %s minutes Due to: %s",name,name2,userid2,minutes,reason)

What I'm trying to do is get the file to a specific folder above the server folder.

Code:
log_to_file("c:/SERVERS/Bans/admin_bans.txt","%s TempBanned %s<%d> for %s minutes Due to: %s",name,name2,userid2,minutes,reason)

In mysearch to find an answer on the forums, I have found out that amxx doesn't want us to use log_to_file anymore and say to use log_amx. Well, that doesn't even give an option for a different file.

Is there any way to write to a log file the preceeds the server in its path???

(If anyone is wondering, I run 5 servers and I would like to log every ban that my admins do to 1 location vs having to check each server's log.)
SilverSquirrl is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-26-2005 , 21:48  
Reply With Quote #2

You could always try the ../ trick and see if it works.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 08-26-2005 , 23:05   Re: log_to_file vs log_amx
Reply With Quote #3

Baka Inu, all things that write and read to files starts in the base folder.

so "addons/text.ini" puts it into the addons folder of the mod running.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Greentryst
WHAT MORE DO THEY WANT?!
Join Date: Mar 2004
Location: ? MAYBE SYRUP+TREES?
Old 08-27-2005 , 01:10  
Reply With Quote #4

Twilight Suzuka, please use only English insults in this forum.
__________________
<Bend3r> Have you waiting for new monsters? Have fix it, but I will not release it an. Gonna fix more monsters and searching after bugs. {3 screenshots attached}
<Locks> that monster looks tight.
<Bend3r> maybe it will slap me.
Greentryst is offline
Send a message via ICQ to Greentryst Send a message via AIM to Greentryst Send a message via MSN to Greentryst Send a message via Yahoo to Greentryst Send a message via Skype™ to Greentryst
BAILOPAN
Join Date: Jan 2004
Old 08-27-2005 , 01:14  
Reply With Quote #5

Err, well log_to_file works a tad differently ;]

If you specify no path information, it logs into the logs folder. If you have a "/" or "\\" char anywhere, it then builds a path relative to the mod dir. Then you can use the .. trick to go up one directory.
__________________
egg
BAILOPAN is offline
SilverSquirrl
New Member
Join Date: Aug 2005
Old 08-27-2005 , 04:21  
Reply With Quote #6

Thanks for the help. I got the ../ to work. here is an example for others that might want to do the same thing.

Code:
  log_to_file("../../../../../bans/admin_bans.txt","%s TempBanned %s<%d> for %s minutes Due to: %s",name,name2,userid2,minutes,reason)

My Directory setup is:

Code:
c:/servers/hlserverns/ns/addons/amxmodx/log/
buy using that code, it now saves the file into
Code:
c:/servers/bans/admin.txt
Like i said before, I run 5 different servers, each one has its own HLDS folder, so this way I can have them all write to one file outside of thier given folder.

(this could be used as part of a plugin that will allow a banlist to be shared throughout all your servers if you run multiple servers on 1 machine.)

Thanks again,
SilverSquirrl
__________________
www.2Frag4Fun.com - An Online Gaming Community
HL1 CSDM 74.200.210.100
HL1 DoD 74.200.210.104
HL2 Hidden #1 "Expert" 74.200.210.109
HL2 HIdden #2 "Beginner" 74.200.210.110
SilverSquirrl is offline
James
Senior Member
Join Date: Dec 2004
Old 11-11-2006 , 15:22   Re: log_to_file vs log_amx
Reply With Quote #7

../../ doesnt work on my linux machine. Is the slash syntax right in the linux too?

i have /usr/local/games/CS/HLDS/cstrike/addons/amxmodx/logs -default folder
i have /usr/local/games/CS/logs folder
and use
format(directory, 99, "../../../../../logs/%s",hostname)
if (!dir_exists(directory))
mkdir(directory)

doesnt work (hostname IS RIGHT i am sure)

Last edited by James; 11-11-2006 at 15:32.
James is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-12-2006 , 12:48   Re: log_to_file vs log_amx
Reply With Quote #8

"../../logs/%s"
[ --<-@ ] Black Rose is offline
James
Senior Member
Join Date: Dec 2004
Old 11-13-2006 , 00:23   Re: log_to_file vs log_amx
Reply With Quote #9

Quote:
Originally Posted by [ --<-@ ] Black Rose View Post
"../../logs/%s"
Thanks it works
James is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode