Raised This Month: $51 Target: $400
 12% 

[HELP] Saving Server Console to Log


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-20-2015 , 14:46   Re: [HELP] Saving Server Console to Log
Reply With Quote #11

You can try this:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <orpheu>

new const StoreConsoleOutPutFile[] = "console_output.ini"

public plugin_init()
{
    
OrpheuRegisterHook(OrpheuGetFunction("Con_Printf"), "OnCon_Printf"OrpheuHookPost)
}

public 
OnCon_Printf(const Dummy[], const Message[])
{
    new 
ConfigsDir[128]
    
get_configsdir(ConfigsDircharsmax(ConfigsDir))
    
format(ConfigsDircharsmax(ConfigsDir), "%s/%s"ConfigsDirStoreConsoleOutPutFile)
    
    new 
FilePointer fopen(StoreConsoleOutPutFile"wt")
    if(
FilePointer)
    {
        
fprintf(FilePointer"%s"Message)
        
fclose(FilePointer)
    }

The sign:
Code:
{
    "name"      : "Con_Printf",
    "library"   : "engine",
    "arguments" : 
    [
        {
            "type" : "char *" 
        },
        {
            "type" : "char *" 
        }
    ],
    "identifiers" : 
    [
        {
            "os"    : "windows",
            "mod"   : "cstrike",
            "value" : [0x55,0x8B,"*",0xB8,"*","*","*","*",0xE8,"*","*","*","*",0xD9,"*","*","*","*","*",0xD8,"*","*","*","*","*",0xDF,"*",0xF6,"*","*",0x7B,"*",0xD9]
        },
        {
            "os"    : "linux",
            "mod"   : "cstrike",
            "value" : "Con_Printf"
        } 
    ]
}
__________________
HamletEagle is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 08-20-2015 , 15:57   Re: [HELP] Saving Server Console to Log
Reply With Quote #12

@aron
all the stuff inside that is from 4 days ago... my server crashed, etc, but there is nothing new inside that

@hamlet
Thanks, i will give it a try this is also a good oportunity to try orpheu, from what i've seen around you can do many interesting things with it

Thanks for everything guys

Last edited by Depresie; 08-20-2015 at 15:57.
Depresie is offline
vlad_slick
Member
Join Date: Jul 2009
Old 08-27-2015 , 11:42   Re: [HELP] Saving Server Console to Log
Reply With Quote #13

Quote:
Originally Posted by wickedd View Post
Well you are wrong. It will log everything that's in the console.
Well, you are wrong. Check it out for yourself. "log on" logs only specific messages, that use logging functions. Just make a plugin that issues "server_print" and that won't get logged. A lot of errors also won't get logged with that command.

As a simple proof:
Type echo text message not visible in the logs in the server console.
It will echo the text in the console but it will NOT be logged.

@HamletEagle:
That's not enough, there are other functions (some that display errors) used for printing to the console.

@Depresie:
I was also interested in something like this and these are the solutions I found:
1) condebug
To start logging to a file called hlds/cstrike/qconsole.log (linux) or hlds/qconsole.log
a) Add condebug your server.cfg
b) Add -condebug to your command line parameters. Also if your sever is hosted somewhere and you can't directly edit the start parameters, you should have an input in the server Control Panel where you can choose the startup map, there you can inject parameters for the command line like so:

This way the new command line would be ./hlds_run -game cstrike +map de_dust2 -condebug
This will log almost everything (99.99% of everything in the console, and about 95% of all the possible errors I've encountered)


2) PIPE
If you have the ability to change the command line (like in 2) b)) you could force the console to be piped to a file with something like this:

This will log 99.9999% of the console messages. (I'm just subtracting 0.0001 in case I miss something)
*The possible downside for this option is that you might break some of the Control Panel functionality that depends on piping the console output.

3) ORPHEU HOOKING
You could search all the functions that output content to the console and hook them. But I think this will take too much work and it won't be 100% reliable.

4) ACTIVE MONITORING
IF you have the console output in the Control Panel:
Use an external server to query the Game Server every x seconds.
When it doesn't respond make a curl request (with the login cookies) to the Control Panel to get the output of the console and save the contents of the console to the external server.

*This is the best way in my opinion because it's functionality doesn't depend on the game server, because it's run independently, but it's complicated to implement. I also have it setup to e-mail me when it crashes.

Last edited by vlad_slick; 08-27-2015 at 11:47.
vlad_slick is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 08-28-2015 , 11:25   Re: [HELP] Saving Server Console to Log
Reply With Quote #14

nice vlad thanks
i think we should have this pinned in a section with tutorials
Depresie is offline
Reply



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 07:52.


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