AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   log_to_file vs log_amx (https://forums.alliedmods.net/showthread.php?t=17143)

SilverSquirrl 08-26-2005 14:01

log_to_file vs log_amx
 
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.)

XxAvalanchexX 08-26-2005 21:48

You could always try the ../ trick and see if it works.

Twilight Suzuka 08-26-2005 23:05

Re: log_to_file vs log_amx
 
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.

Greentryst 08-27-2005 01:10

Twilight Suzuka, please use only English insults in this forum.

BAILOPAN 08-27-2005 01:14

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.

SilverSquirrl 08-27-2005 04:21

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

James 11-11-2006 15:22

Re: log_to_file vs log_amx
 
../../ 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)

[ --<-@ ] Black Rose 11-12-2006 12:48

Re: log_to_file vs log_amx
 
"../../logs/%s"

James 11-13-2006 00:23

Re: log_to_file vs log_amx
 
Quote:

Originally Posted by [ --<-@ ] Black Rose (Post 402597)
"../../logs/%s"

Thanks it works


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

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