Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Tugamars - Today at 12:13 AM
- Hello
- Anyone here ?
- sirsquidness - Today at 12:14 AM
- hello!
- yes
- Tugamars - Today at 12:14 AM
- You are one of the project manager on Opensourcelan, right ?
- sirsquidness - Today at 12:16 AM
- yeah, that's me
- Tugamars - Today at 12:16 AM
- First of all, nice to meet you 😃
- I am here trying to understand your log-parser for srcds logs, and i cant just understand where you call the file to be parsed. Can you give me a light ?
- sirsquidness - Today at 12:17 AM
- Sure thing, just a moment
- The wrapper I used to test it as I was writing is here https://github.com/OpenSourceLAN/better-csgo-log-parser/blob/master/test.ts which opens a file and reads it line by line, feeding each line in to the parser
- GitHub
- OpenSourceLAN/better-csgo-log-parser
- better-csgo-log-parser - A CSGO log parser that works
- Tugamars - Today at 12:19 AM
- okay, but in what line you can the file ? its the 5 line ?
- call*
- sirsquidness - Today at 12:20 AM
- yeah, line 5
- Tugamars - Today at 12:21 AM
- I cant just understand how i can call a file like log-30-06-2016.log, from what u got here --> fs.readFileSync(process.argv[2]).toString().split("\n");
- sirsquidness - Today at 12:21 AM
- var fileContents = fs.readFileSync(process.argv[2]).toString().split("\n");
- fs.readFileSync takes a filename and returns the whole text of the file in a Buffer object. We call .toString() on the buffer so that it's a string. And then split it by line so that we can pass each line in to the parser individually
- process.argv[2] is the filename - in the test.js file, I pass it as a command line argument, so it ends up in argv
- you can replace process.argv[2] with "log-30-06-2016.log" or another variable with a filename, and it'll open that file
- Tugamars - Today at 12:22 AM
- oh ok. But var process is related to a library, no ?
- sirsquidness - Today at 12:23 AM
- Correct. process is a node library. You can see the documentation for it here https://nodejs.org/dist/latest-v6.x/docs/api/process.html
- Specifically https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_process_argv for the way command line arguments work 😃
- Tugamars - Today at 12:24 AM
- Ok, and if i replace process.argv[2] with "log-30-06-2016.log", it will return exactly the same result ? O.o
- sirsquidness - Today at 12:28 AM
- here is a different and shorter script that will read the file
- var fs = require('fs');
- var logparser = require('./index');
- var filenameToRead = "log-30-06-2016.log";
- var parser = new logparser();
- var fileContents = fs.readFileSync(filenameToRead).toString().split("\n");
- for (var i = 0; i < fileContents.length; i++) {
- var parsedLine = parser.parseLine(fileContents[i]);
- console.log(parsedLine);
- }
- so that will read every line in the log file and print it to the console
- Tugamars - Today at 12:30 AM
- Ok, replacing that on the test.js is the same, thats it ?
- sirsquidness - Today at 12:31 AM
- yup, you can replace test.js with that or make another file in the same directory
- Tugamars - Today at 12:32 AM
- Ok, and than it will print the things on a console '
- the console*
- sirsquidness - Today at 12:34 AM
- yes
- What's the project you are working on? 😃
- Tugamars - Today at 12:34 AM
- If you see this, its done with ebot
- (Click on the map to see what im talking)
- not that
- Wrong thing
- What im talking is something like that, Scorebot + log. But i just can do it with eBot, and to do with ebot you need sql rights on the database, wich almost no one gives
- So i need to do it with a general thing, like LOG
- sirsquidness - Today at 12:37 AM
- cool 😃
- Tugamars - Today at 12:37 AM
- But my knowlege of node/js is almost 0 :/
- sirsquidness - Today at 12:38 AM
- you may also be interested in https://github.com/OpenSourceLAN/csgo-competition-manager/tree/master/log-receiver this folder
- GitHub
- OpenSourceLAN/csgo-competition-manager
- csgo-competition-manager - A simple web tool to manager CSGO competitive servers
- you can tell a srcds/csgo server to send its log over the network
- Tugamars - Today at 12:39 AM
- i checked that, but it works on server-side, no?
- sirsquidness - Today at 12:39 AM
- the files in that folder will listen for the network log messages and let you update statistics live
- it can be anywhere with internet access
- Tugamars - Today at 12:40 AM
- definedSources: [
- { address: "10.0.0.100", port: 27015, password: "12345" }
- thats where i define where to get the log from ?
- (its on the test.ts)
- sirsquidness - Today at 12:42 AM
- The reason that is there is that there is optional security on the log protocol
- If you do not set a password on the protocol using the srcds cvar sv_logsecret (I think), you do not need to put anything in there
- But if you do set a log password in your srcds instance, you do need to enter the server in to the definedSources
- Tugamars - Today at 12:45 AM
- yeah, i figured it will work like that. But if you put log_adress my.ip, and dont use sv_logsecret, you need to define the ip of the server anyway ?
- sirsquidness - Today at 12:46 AM
- By default it will accept logs from any server
- The library only receives the UDP packets from the servers, it does not connect or send anything to the servers, so it doesn't need to know what the servers are
- Tugamars - Today at 12:47 AM
- hm. And it will automatic parse the log and print it to somewhere or just receive ?
- sirsquidness - Today at 12:49 AM
- you register a handler with it
- l.on("data", (d: Listener.LogMessage) => {
- console.log("Got: ", parser.parseLine(d.message));
- });
- When it receives a packet, it will read it and emit a data event, which will be handled by that
- You can read more about how the event emitter works here https://nodejs.org/dist/latest-v6.x/docs/api/events.html#events_class_eventemitter
- Tugamars - Today at 12:51 AM
- Thank you so much, man. Im understanding how it works. Just need to see how to adapt it to my reality
- Again, thank you, you have been very helpful and its quite rare to see people like that. Thanks again
- sirsquidness - Today at 12:52 AM
- No problem.
- Also, since you're new to javascript, watch out - I wrote these in TypeScript, which gets turned in to javascript. So you will need to do
- npm install -g [email protected]
- tsc
- if you haven't already to compile the typescript to javascript
- Tugamars - Today at 12:53 AM
- Yeah, i figured that. Thanks 😃
- Im gone leave, thanks again 😃
- Escolher Ficheiros
Advertisement
Add Comment
Please, Sign In to add comment