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

[TF2] LogUploader (v1.4, 2013-05-05)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Duckeh
Junior Member
Join Date: Mar 2013
Plugin ID:
3567
Plugin Version:
1.4
Plugin Category:
Statistical
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    A plugin for automatically uploading logs to "logs.tf" after a match finishes
    Old 03-13-2013 , 09:42   [TF2] LogUploader (v1.4, 2013-05-05)
    Reply With Quote #1

    Description

    This plugin automatically uploads your TF2 match log to logs.tf using your own logs.tf API key.
    Source and compiled plugin can be found on github

    When a round ends, it starts looking for a log that has been edited in the last 60 seconds.
    It uses cURL to do a POST request to logs.tf and prints the response in chat for everyone to see.
    A response would look (if everything works properly) like this:
    Code:
    [LogUploader] Log Id: 33062 
    [LogUploader] Log link: http://logs.tf/33062
    So in this example, the log has been uploaded successfully and can be found at "http://logs.tf/33062".


    CVAR/Command list


    Code:
    sm_logup_apikey - Set your logs.tf API key to use for uploading of logs
    sm_logup_title - Set the title for your logs on logs.tf


    Changelog

    Code:
    2013-05-05 (v1.4)
    * Removed error messages upon failing, they're not really of much use to the end user anyway
    * Fixed the way of locating the log, plugin now flushes the log, waits 5 seconds for everything to be written to disk fully and then uploads the log.  This should fix issues with logs not including the last round or logs not being located at all
    * Also use sv_logsdir for log location
    * Use Nikkii's fixed JSON include, now the plugin simply prints the log ID and link, huge huge thanks to Nikkii for his work on this
    
    2013-03-16 (v1.3)
    * Reformatted code - thanks for your example Nikkii! (Still need to fix a few things, though)
    
    2013-03-13 (v1.2)
    * Fixed a handle not being closed
    
    2013-03-13 (v1.1)
    * Using threaded cURL to avoid massive lag on round end
    
    2013-03-13 (v1.0)
    * Initial release.


    Installation instructions


    First and foremost, make sure the cURL extension is installed!

    Install the plugin to the plugin directory and load it on the server once.
    This will create the config file in tf/cfg/sourcemod called "LogUploader.cfg".
    Enter your logs.tf API-Key in that config file and reload the plugin on the server.
    Now you're all set and good to go.

    NOTE! If upgrading from 1.2 to 1.3, you have to add the "sm_logup_title" cvar to the LogUploader.cfg file manually.

    Dependencies
    cURL extension
    Nikkii's fixed JSON include <-- Only needed if you compile the plugin yourself

    Known bugs/problems
    Quote:
    1. My first SourceMod plugin, code could probably be a bit neater
    2. Haven't really had the chance to do any extensive testing on this, so there could be any number of weird things happen! By all means let me know and I can maybe try to fix it..
    3. It doesn't compile on the website because it requires the cURL and JSON includes.
    Download compiled plugin here:
    https://github.com/remydb/LogUploade...log_upload.smx


    Last edited by Duckeh; 05-05-2013 at 09:51.
    Duckeh is offline
    Root_
    Veteran Member
    Join Date: Jan 2012
    Location: ryssland
    Old 03-13-2013 , 14:45   Re: [TF2] LogUploader (v1.1, 2013-03-13)
    Reply With Quote #2

    Nice one! I am using logs.tf service and that stuff is just great!
    It is possible to use Socket or SteamTools instead of cURL ?
    __________________


    dodsplugins.com - Plugins and Resources for Day of Defeat
    http://twitch.tv/zadroot
    Root_ is offline
    Duckeh
    Junior Member
    Join Date: Mar 2013
    Old 03-13-2013 , 14:48   Re: [TF2] LogUploader (v1.1, 2013-03-13)
    Reply With Quote #3

    I tried doing it with SteamTools but couldn't get a properly formed POST request.
    Then again, there's not much documentation to go on with all these sourcemod extensions, so it was all a load of looking at examples and stuff.

    I imagine it's possible to do it with Socket and maybe also SteamTools, but I wouldn't know how.
    So for now this plugin will only use cURL.

    Last edited by Duckeh; 03-13-2013 at 14:51.
    Duckeh is offline
    nTraum
    Junior Member
    Join Date: Aug 2012
    Old 03-14-2013 , 18:21   Re: [TF2] LogUploader (v1.2, 2013-03-13)
    Reply With Quote #4

    Great work! Would be cool if the SM plugin would paste the URL of the uploaded automatically in allchat after the match.
    nTraum is offline
    Thrawn2
    Veteran Member
    Join Date: Apr 2009
    Old 03-14-2013 , 20:35   Re: [TF2] LogUploader (v1.2, 2013-03-13)
    Reply With Quote #5

    You'll need to fix a few things:
    • get rid of the global variables
    • You don't need to tag integers
    • Remove the sm_log command. What's its use?
    • use PLATFORM_MAX_PATH for your path variables
    • use sizeof() instead of hard coded lengths
    • What happens if I end two matches in 60s? This method of getting the last log file is not error-prone at all.
    • General lack of error checking (e.g. create a directory in your logs folder).
    • What's being done to prevent uploading non-match logs? E.g. matches that got restarted before anyone could reach mid.
    and some other minor things.
    __________________
    einmal mit profis arbeiten. einmal.
    Thrawn2 is offline
    Nikkii
    Member
    Join Date: Feb 2012
    Old 03-14-2013 , 23:28   Re: [TF2] LogUploader (v1.1, 2013-03-13)
    Reply With Quote #6

    Quote:
    Originally Posted by Root_ View Post
    Nice one! I am using logs.tf service and that stuff is just great!
    It is possible to use Socket or SteamTools instead of cURL ?
    Socket extension would work but you'd have to form a whole multipart/form-data request with boundaries and everything to upload it correctly, but I bet it'd work just as well as the cURL extension

    I'll take the challenge and see if I can make it work, since I'm really interested in this plugin, it makes the last 30 minutes of work on a web panel to upload logs obsolete

    Edit: Here is what I have so far, however I've noticed a few things that make it really unreliable like #2 on your post, and this also doesn't get a response from logs.tf even though the request size is just fine (I've debugged it on 4 log files, all of them showing the correct data lengths, however logs.tf doesn't respond at all, even through a raw response)

    http://paste.ee/r/RoQeD

    Requires http://forums.alliedmods.net/showthread.php?t=195557 for JSON.

    It'll upload in valid HTTP Multipart/form-data POST, but somewhere a size calculation or something is off so it won't work right. cURL is obviously better for this application, but manually uploading is still better than any auto uploader until it is certain the data is written to file (You COULD call log off before uploading and it should write the rest of the buffer to file), I don't expect anyone to fix it so it's more of an example here

    Most likely problems:
    1. Size is incorrectly calculated
    2. The request is malformed somewhere
    3. Logs.tf just isn't accepting it
    __________________
    Owner of ProbablyAServer, a server without game changing mods and donation benefits

    RCON Helper | [TF2] LogUpload | CCC Donator Tags | PHP Steam API Wrapper

    Last edited by Nikkii; 03-15-2013 at 03:11.
    Nikkii is offline
    Duckeh
    Junior Member
    Join Date: Mar 2013
    Old 03-15-2013 , 04:26   Re: [TF2] LogUploader (v1.2, 2013-03-13)
    Reply With Quote #7

    Wow, you did that quick, Nikki!
    And I hadn't seen that JSON include, looks awesome.

    Get rid of the global variables
    So that would be the count variable I need to move, do I also have to get rid of the CURL_DEFAULT_OPTS?

    You don't need to tag integers
    Alright!

    Remove the sm_log command. What's its use?
    Yeah, that was a left-over command from testing, will remove it.

    use PLATFORM_MAX_PATH for your path variables
    Don't know what that is or how it works.
    I saw some examples of that being used with BuildPath, but I thought that was just for paths inside "addons/sourcemod/"

    use sizeof() instead of hard coded lengths
    Alright.

    What happens if I end two matches in 60s? This method of getting the last log file is not error-prone at all.
    Depends, if you reload the config it'll probably only upload the first match, as the second one will stay in the buffer (most likely). If you do two matches without reloading the config it'll probably only upload on the second one, as the first one then stays buffered.

    General lack of error checking (e.g. create a directory in your logs folder).
    Yup..

    What's being done to prevent uploading non-match logs? E.g. matches that got restarted before anyone could reach mid.
    Well, if a match gets restarted the logs won't upload as the events aren't triggered. The next match would more than likely take more than 60 seconds so that it wouldn't upload the log for the non-match.
    Also, other non-match-related logs shouldn't get uploaded as they shouldn't get edited during a match and thus their timestamp shouldn't change..
    I understand it's a rather crude way to go about grabbing the last log, I just wouldn't know any other way of doing it. Or maybe I could, but my knowledge of SourcePawn is rather limited so I wouldn't have a clue how to do something like checking which log has the highest number.

    Last edited by Duckeh; 03-15-2013 at 04:27.
    Duckeh is offline
    Alfie
    Junior Member
    Join Date: Dec 2009
    Old 03-15-2013 , 14:37   Re: [TF2] LogUploader (v1.2, 2013-03-13)
    Reply With Quote #8

    It says LogUpload.cfg in the OP, but it makes LogUploader.cfg. Confused me a bit
    __________________
    Alfie is offline
    Duckeh
    Junior Member
    Join Date: Mar 2013
    Old 03-15-2013 , 14:38   Re: [TF2] LogUploader (v1.2, 2013-03-13)
    Reply With Quote #9

    Sorry about that mate, updated OP.
    Duckeh is offline
    Nikkii
    Member
    Join Date: Feb 2012
    Old 03-15-2013 , 16:22   Re: [TF2] LogUploader (v1.2, 2013-03-13)
    Reply With Quote #10

    Quote:
    Originally Posted by Duckeh View Post
    Wow, you did that quick, Nikki!
    And I hadn't seen that JSON include, looks awesome.
    Not even sure if it will work, but it should since it was only posted in late 2012

    The parser hasn't even gotten that far unfortunately, since logs.tf won't reply to my request when there's actual log data

    Quote:
    Originally Posted by Duckeh View Post
    What's being done to prevent uploading non-match logs? E.g. matches that got restarted before anyone could reach mid.
    Well, if a match gets restarted the logs won't upload as the events aren't triggered. The next match would more than likely take more than 60 seconds so that it wouldn't upload the log for the non-match.
    Also, other non-match-related logs shouldn't get uploaded as they shouldn't get edited during a match and thus their timestamp shouldn't change..
    I understand it's a rather crude way to go about grabbing the last log, I just wouldn't know any other way of doing it. Or maybe I could, but my knowledge of SourcePawn is rather limited so I wouldn't have a clue how to do something like checking which log has the highest number.
    I looked into this last night and found a few things:
    1. Check mp_tournament, it should be 1 (This is in my revision above)
    2. Lower the log time to 10 seconds, calling 'log on' to reset/flush the old log (It should pick up the old log instead of the new one)
    __________________
    Owner of ProbablyAServer, a server without game changing mods and donation benefits

    RCON Helper | [TF2] LogUpload | CCC Donator Tags | PHP Steam API Wrapper
    Nikkii 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 01:37.


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