Menu

Log rotate and unix timestamp

2014-05-14
2014-05-14
  • Milorad Jovanovic

    Okay, i've been using boos.log libray for a while now, But at this moment, i have some special request, so here it is:

    first, i want instead of boost posix time, to use unix timestamp, function like time(), or chrono::now(), i've implemented it like attrs::make_function(&to_time)) and then used it in stream. Question is: is it better to make my own attribute, and then use it, or just to use this make_function wrapper?

    and second, i want to rotate file at the begging of every hour(not posix::hour(1)) i dont need time duration i need point in time. i also used a function wrapper keywords::time_based_rotation = boost::bind(&log::is_it_time_to_rotate,this), is there better way? because i find this not efficient, when i use same function 2 or 3 times?

    Regards.

     
    • Andrey Semashev

      Andrey Semashev - 2014-05-14
      1. You can use basic_clock attribute with your custom time traits. Performance wise make_function and basic_clock should be equivalent.

      2. Custom predicate for time-based rotation is the intended way of extension. I'm not sure what inefficiency you mean. The library uses the same interface for its own time-based rotation predicates.

       

Log in to post a comment.