Skip to content

Loading…

Eliminate human log format #567

Closed
wants to merge 35 commits into from

5 participants

@htgoebel

The implementation was not correct: it changes the log-format for all
loggers. Doing it right is not worth the effort, esp. since local
log-files are using ISO timestamps meanwhile.

Please apply this after `use-standard-logging.module.

htgoebel added some commits
@htgoebel htgoebel Do not use a global `logger` in test_logging.
This is a preparation for switching to the new logging module. This
may not be perfect, since there are still global variables in shinken.log,
but all test-cases still pass.
5c8fe3f
@htgoebel htgoebel Fix test-case: logger.set_level() now accepts names (strings), too. baf569e
@htgoebel htgoebel New function `send_result()` to avoid misusing loggers for this.
Currently `send_result()` is only a wrapper to console_logger.info(),
but this will be changed as soon as the standard-log-system is used.
b87bc02
@htgoebel htgoebel Remove test-cases no longer valid.
The interface will change:
- no more global variable `human_format`
- Log.log() require to level to be passed and not be used in shinken.
4c3ec0c
@htgoebel htgoebel Fix test-case: private `_level` is no public `level`. 5af37be
@htgoebel htgoebel Adopt test-cases: `logger` will no longer write to stdout. 0f78ad6
@htgoebel htgoebel Fix test-case: remove a duplicate line. 565e1ab
@htgoebel htgoebel Adopt test-cases: log-messages will have level upper-case and less sp…
…aces.
849bddb
@htgoebel htgoebel Adopt test-case: local log will get a single time-stamp. 2ed4a6f
@htgoebel htgoebel Clean: Remove a left-over print statement. 17384bb
@htgoebel htgoebel Base `shinken.log.Log` on std-Python `logging.Logger`.
Still to do: send broks, local logging, human-format.
06f4705
@htgoebel htgoebel Use a std TimedRotatingFileHandler for local log. e884e74
@htgoebel htgoebel Use a log-handler for sending the Broks. 20b205e
@htgoebel htgoebel Use a Formatter w/ different format if "human format" is selected. ac8a29b
@htgoebel htgoebel Make `Log.set_level()` and alias for std `setLevel()`.
Todo: Remove this alias when cleaning up.
a536b50
@htgoebel htgoebel Create main logger using `logging.getLogger()` (adding it to the hier…
…archy).
c8d7620
@htgoebel htgoebel Make console_logger a standard logger using a StreamHandler. 2c0ef66
@htgoebel htgoebel Take definition of log-levels from std Python logging module. b6a99a9
@htgoebel htgoebel Add test-case for console_logger.
This one is writing messages to the console, broker and (if applicable)
to the local log-file.
1d2c1cd
@htgoebel htgoebel Fix: Need to set format for console_logger. 8d780e4
@htgoebel htgoebel Clean: Remove unused import and uselessly overwritten method. 7d0f045
@htgoebel htgoebel Clean: Remove useless alias `Log.set_level()`, use `setLevel()` instead. 4d1edc0
@htgoebel htgoebel noch zu entfernen von __init__ 3922ff8
@htgoebel htgoebel Clean: Remove useless alias `Log.get_level()`, use `getEffectiveLevel…
…()`.
0e1792f
@htgoebel htgoebel Clean: Remove `Log.get_level_id()`, use std `getLevelName()` instead. 51be66e
@htgoebel htgoebel Add test-suite for `logger.send_result()`. 95c65bf
@htgoebel htgoebel Fix typo in comment. f643778
@htgoebel htgoebel Make `logging.send_result` log with level DEBUG and send Brok itself. 6e63081
@htgoebel htgoebel Enhance test-case: assert logging level is as expected. 08f91f3
@htgoebel htgoebel Fix log-level when logging config-errors in business-rules.
This is required to make test_business_correlator.py pass.
247b4c8
@htgoebel htgoebel Enhance test-case: assert logging level is as required to get messages. 176cd46
@htgoebel htgoebel Fix: increase log-level for some messages, so their are logged by def…
…ault.
bb7a532
@htgoebel htgoebel Fix: Remove usage of `logger.quit()` (which no longer exists). aaaa711
@htgoebel htgoebel Fix: get_log_match() did not prepare the broks prior to searching. b531a02
@htgoebel htgoebel Eliminate `human_timestamp_log`.
The implementation was not correct: it changes the log-format for all
loggers. Doing it right is not worth the effort, esp. since local
log-files are using ISO timestamps meanwhile.
eaec6d0
@xkilian

How much risk is there to integrating this patch. Should we wait after Shinken 1.2.1? (first bug fixe release of 1.2)

I will test this on tuesday.

@naparuba
Owner
@xkilian

Well, we should aim to have everything ready by friday. So come monday morning, new users can download 1.2.1 and get cooking. After that 1.2.2 for whatever comes out of next week or the two weeks after that…

Which is why we need to have the discussion about stable versus dev.

@htgoebel

Argl! This discussion as nothing to do with this pull-request. It should not be discussed as a side-note to some pull-request, but on the mailing-list.

@xkilian

Yes, of course, I tend to go off on tangents…

I for one, would like to see better logging for 1.2.x. But I am a little weary at breaking more things that are not covered by the test cases. But supporting Shinken with the current logs is currently sub-optimal.
Hartmut, can this series of pull requests be put in fairly safely. I think we have a good grasp on the logging issues that can happen.

What do you think? Your changes would handle issue #583. I went through over 3/4s of your change request and I agree with most everything in there.

@htgoebel

@xkilian: Please mind: This pull request is for eliminating human-log-format. It is based on pull #566.

For fixing issue #583, I would not apply this pull-request (nor #566) as it also introduces other changes.
You may want to cherry-pick b87bc02, 95c65bf and 6e63081.

@xkilian

Tried cherry picking the 4-5 commits that seemed to be required, but I can'tget it to be clean and functional.

I merged both your pull requests related to logging and tested using that. Looks good.

One question: Does the brokhandler call at the bottom of log.py need a try catch statement, as _broker.add is a remote method. I was not sure if it should be a _brokhandler.handleError?

@xkilian

I can issue a new pull request with the small corrections needed to merge into 1.2.

--- edit ---
Argh.. me and git had a problem. I suggest you correct the file that prevents auto-merge, add the missing try (if applicable) and I vote for a merge for 1.2.1.

@xkilian

I merged the changes back into the latest Shinken master and logging doesn't seem to be working correctly. All the daemon log files are empty with only a single line logged. Merged std-logging + no human logging.

@naparuba
Owner

Hi,

what is the state of this ticket? I'm ok for removing the human_format thing from conf and code. Was an error to add it.

@Frescha
Collaborator

Any updates?

@naparuba naparuba added the Bug label
@Seb-Solon Seb-Solon referenced this pull request
Closed

Shinken 2.2 Roadmap #1175

6 of 6 tasks complete
@Seb-Solon Seb-Solon self-assigned this
@Seb-Solon

Merged with #1201. Thanks a lot @htgoebel :beers:

@Seb-Solon Seb-Solon closed this
@Seb-Solon Seb-Solon was unassigned by naparuba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 2, 2012
  1. @htgoebel

    Do not use a global `logger` in test_logging.

    htgoebel committed
    This is a preparation for switching to the new logging module. This
    may not be perfect, since there are still global variables in shinken.log,
    but all test-cases still pass.
  2. @htgoebel
  3. @htgoebel

    New function `send_result()` to avoid misusing loggers for this.

    htgoebel committed
    Currently `send_result()` is only a wrapper to console_logger.info(),
    but this will be changed as soon as the standard-log-system is used.
  4. @htgoebel

    Remove test-cases no longer valid.

    htgoebel committed
    The interface will change:
    - no more global variable `human_format`
    - Log.log() require to level to be passed and not be used in shinken.
  5. @htgoebel
  6. @htgoebel
  7. @htgoebel
  8. @htgoebel
  9. @htgoebel
  10. @htgoebel
  11. @htgoebel

    Base `shinken.log.Log` on std-Python `logging.Logger`.

    htgoebel committed
    Still to do: send broks, local logging, human-format.
  12. @htgoebel
  13. @htgoebel
  14. @htgoebel
  15. @htgoebel

    Make `Log.set_level()` and alias for std `setLevel()`.

    htgoebel committed
    Todo: Remove this alias when cleaning up.
  16. @htgoebel
  17. @htgoebel
  18. @htgoebel
  19. @htgoebel

    Add test-case for console_logger.

    htgoebel committed
    This one is writing messages to the console, broker and (if applicable)
    to the local log-file.
  20. @htgoebel
  21. @htgoebel
  22. @htgoebel
  23. @htgoebel

    noch zu entfernen von __init__

    htgoebel committed
  24. @htgoebel
  25. @htgoebel
  26. @htgoebel
  27. @htgoebel

    Fix typo in comment.

    htgoebel committed
  28. @htgoebel
  29. @htgoebel
  30. @htgoebel

    Fix log-level when logging config-errors in business-rules.

    htgoebel committed
    This is required to make test_business_correlator.py pass.
  31. @htgoebel
  32. @htgoebel
  33. @htgoebel
  34. @htgoebel
  35. @htgoebel

    Eliminate `human_timestamp_log`.

    htgoebel committed
    The implementation was not correct: it changes the log-format for all
    loggers. Doing it right is not worth the effort, esp. since local
    log-files are using ISO timestamps meanwhile.
Something went wrong with that request. Please try again.