Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error reporting #21

Closed
tobyweston opened this issue Oct 17, 2017 · 2 comments
Closed

Better error reporting #21

tobyweston opened this issue Oct 17, 2017 · 2 comments

Comments

@tobyweston
Copy link
Owner

tobyweston commented Oct 17, 2017

Make the log viewable in the app and show dates / times.

Bit of a shame as I made an effort to display interesting startup output (below)

Starting temperature-machine (server mode)...
RRD initialising for 'study', 'bedroom1', 'bedroom2', 'bedroom3', 'outside', 'kitchen', 'lounge' (with up to 5 sensors each)...Ok
Starting Discovery Server, listening for 'study', 'bedroom1', 'bedroom2', 'bedroom3', 'outside', 'kitchen', 'lounge'...
Listening for broadcast messages...
Monitoring sensor file(s) on 'study' 
	/sys/bus/w1/devices/28-031591c760ff/w1_slave
Temperature spikes greater than +/-25% will not be recorded
HTTP Server started on http://127.0.1.1:11900
UnexpectedError(Failed to PUT temperature data to http://127.0.1.1:11900/temperature, response was 502 Bad Gateway: Error in RRD Bad sample time: 1507971519. Last update time was 1507971519, at least one second step is required)

Which would get muddled a little if I swap in an arbitrary logging framework:

2017-10-16 22:50:58:391 [main] INFO Starting temperature-machine (server mode)...
2017-10-16 22:50:58:427 [main] INFO RRD initialising for 'test', 'test2' (with up to 5 sensors each)...
2017-10-16 22:50:58:439 [main] INFO Ok
2017-10-16 22:51:09:128 [main] INFO Starting Discovery Server, listening for 'test', 'test2'...
2017-10-16 22:51:09:136 [temperature-machine-discovery-server-1] INFO Listening for broadcast messages...
2017-10-16 22:51:09:170 [main] INFO Monitoring sensor file(s) on 'MacBook-Pro' 
	/Users/toby/Workspace/github/temperature-machine/src/test/resources/more_examples/28-000005e2fdc2/w1_slave
	/Users/toby/Workspace/github/temperature-machine/src/test/resources/more_examples/28-000005e2fdc3/w1_slave

2017-10-16 22:51:09:317 [main] INFO Temperature spikes greater than +/-31% will not be recorded
2017-10-16 22:51:14:916 [main] INFO HTTP Server started on http://10.0.1.7:11900
2017-10-17 20:08:15:895 [temperature-machine-discovery-server-1] INFO Listening for broadcast messages...
2017-10-17 20:08:25:885 [temperature-machine-discovery-server-1] INFO Listening for broadcast messages...
2017-10-17 20:08:40:898 [temperature-machine-discovery-server-1] INFO Discovery server shutdown
tobyweston added a commit that referenced this issue Oct 17, 2017
…'s a transitive dependency already brought in.
tobyweston added a commit that referenced this issue Oct 17, 2017
… folder where we should be able to serve it via HTTP
tobyweston added a commit that referenced this issue Oct 17, 2017
tobyweston added a commit that referenced this issue Oct 20, 2017
@tobyweston
Copy link
Owner Author

tobyweston commented Oct 26, 2017

NB. the current approach will take a standard text based log file and parse it on the fly to a List[LogMessage]. This has the problem where the LogParser can handle newlines and parse multi-line log messages into valid LogMessages, any client of the parser can't read a file a (conventional) line at a time.

So anything that goes Source.fromFile(...).getLines() can not feed the LogParser.

Alternatives might be to write the log file as JSON in the first place (which I didn't do first time round as I wanted a super-lightweight logging framework) or use a custom line ending delimiter in the log file (\u0000 springs to mind).

So instead of:

Source.fromFile(source).getLines()

You'd use a Scanner:

new Scanner(new File(source)).useDelimiter("\u0000").asScala

tobyweston added a commit that referenced this issue Oct 31, 2017
…g, prepend the null character to all log messages (using the date pattern) and add the line ending to the actual end of a line in the ErrorLogger. Upshot is that we can now accept \n characters within log messages
tobyweston added a commit that referenced this issue Oct 31, 2017
tobyweston added a commit that referenced this issue Nov 2, 2017
tobyweston added a commit that referenced this issue Nov 12, 2017
@tobyweston
Copy link
Owner Author

tobyweston commented Nov 14, 2017

Still to do:

  • Swap out naive logger implementation for something more grown up. Specifically, limit log size and rollover after say 10mb

tobyweston pushed a commit that referenced this issue Dec 14, 2017
tobyweston added a commit that referenced this issue Dec 14, 2017
…to limit the log size). May have broken the log parser with \u0000
tobyweston added a commit that referenced this issue Jan 1, 2018
…ans we can drop the \u0000 silliness. Log4J2 is a dick to test though.
@tobyweston tobyweston removed the in play label Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant