Logging

marko89kv8 years ago

Hello,

is it possible to use org.traccar.helper.Log class inside one of the protocol decoder classes? I would like to log out few values, because I'm modifying watch protocol.
I have imported it inside WatchProtocolDecoder.java, and calling Log.debug("log something") inside of the decode() method, but I don't see that in the tracker-server.log file when the device sends its position.

Thank you.

Anton Tananaev8 years ago

It is definitely possible. You must be doing something wrong if it's not logged, or maybe the code that you are expecting to be called, doesn't get called.

marko89kv8 years ago

This is the excerpt from what I've added

position.set(Position.KEY_SATELLITES, parser.nextInt());
position.set(Position.KEY_GSM, parser.nextInt());
position.set(Position.KEY_BATTERY, parser.nextInt());
position.set("steps", parser.nextInt());
////////////////////////////////////////
int rollover = parser.nextInt();
int terminalStatus = parser.nextInt();
Log.warning("terminalState: " + terminalStatus);
////////////////////////////////////////
            
return position;

And this had to be added to the Pattern Builder to get the terminalStatus number:

private static final Pattern PATTERN_POSITION = new PatternBuilder()
            .text(",")
            .number("(dd)(dd)(dd),")             // date (ddmmyy)
            .number("(dd)(dd)(dd),")             // time
            .expression("([AV]),")               // validity
            .number(" *(-?d+.d+),")              // latitude
            .expression("([NS]),")
            .number(" *(-?d+.d+),")              // longitude
            .expression("([EW])?,")
            .number("(d+.d+),")                  // speed
            .number("(d+.?d*),")                 // course
            .number("(d+.?d*),")                 // altitude
            .number("(d+),")                     // satellites
            .number("(d+),")                     // gsm
            .number("(d+),")                     // battery
            .number("(d+),")                     // steps
////////////////////////////////////////////////////////////////////////////////
            .number("(d+),")                     // rollover
            .number("(d+),")                     // terminalStatus
////////////////////////////////////////////////////////////////////////////////
            .number("d+,")                       // tumbles
            .any()
            .compile();
Anton Tananaev8 years ago

I recommend to debug the code and see what's happening.

marko89kv8 years ago

Sorry, works fine now, I forgot to switch the tracker-server.jar on the target machine.