Increase precision of apache log to include milliseconds - apache

I have modified the configuration of rsyslogd to disable RSYSLOG_TraditionalFileFormat.
But still the apache log /var/log/apache/error.log is displaying only second-precission.
Is there something else that needs to be configured?

At http://httpd.apache.org/docs/current/mod/mod_log_config.html
you see differemt time formats including mili seconds
Just change from
%t
to
%{%d/%b/%Y:%T}t-%{msec_frac}t for miliseconds
or
%{%d/%b/%Y:%T}t-%{usec_frac}t for microsecs
Example:
16/Mar/2013:22:44:34-634
16/Mar/2013:22:44:34-634200
Documenation apache
%t Time the request was received, in the format [18/Sep/2011:19:18:28 -0400]. The last number indicates the timezone offset from GMT
%{format}t The time, in the form given by format, which should be in an extended strftime(3) format (potentially localized). If the format starts with begin: (default) the time is taken at the beginning of the request processing. If it starts with end: it is the time when the log entry gets written, close to the end of the request processing. In addition to the formats supported by strftime(3), the following format tokens are supported:
sec number of seconds since the Epoch
msec number of milliseconds since the Epoch
usec number of microseconds since the Epoch
msec_frac millisecond fraction
usec_frac microsecond fraction
These tokens can not be combined with each other or strftime(3) formatting in the same format string. You can use multiple %{format}t tokens instead.
strftime(3) formatting
http://man7.org/linux/man-pages/man3/strftime.3.html

Related

Tmux pad format string

I want to pad a format string to a certain length. For example, the Tmux Battery plugin introduces the battery_percentage format string. I can use this in the status bar as #{battery_percentage}. The battery percentage values can be:
Between 0% and 9% (One Digit).
Between 11% and 99% (Two Digits).
Exactly 100% (Three Digits).
I want the format string to always be displayed 3 digits, padded with spaces at the end, how can I achieve that?
I saw that there is the format #{pN:variable} in this page, but it did not work when I tried to use it with format strings, even though at the end they are variables. Maybe I just did not know how to use it, I don't know...
Looking at the plugin startup code, battery.tmux, you can see that ${battery_percentage} is actually converted to #($CURRENT_DIR/scripts/battery_percentage.sh), which is a request to run a script. I don't know if #{p3:#(...)} can be made to work since this is not a simple variable.
You could always edit the plugin shell script to return the padded string (assuming tmux keeps the leading spaces).

Making chunks of audio files using SoX if start and end times are known

I have a 10 minute audio which I want to break in chunks of time as follows:
(the format is mm:ss.frac)
1. 1.wav -> 00.000 - 20.271
2. 2.wav -> 20.272 - 47.550
3. 3.wav -> 47.551 - 01:20.562
I tried using the trim command like such
sox infile outfile trim 0.000 20.271 However the format is trim start [length]
Worst case, I will have to calculate the durations for individual chunks. Is there another way?
I found that the simplest solution is to write the command as such:
sox infile outfile start =end
The audio is not sent to the output stream until the start location is reached and specifying an end location can be done by using the "=" sign with the end time.
So the code would now be, for instance:
sox forth.wav 10.wav trim 303.463 =353.790
Link to the docs http://manpages.ubuntu.com/manpages/precise/man1/sox.1.html
Relevant excerpt:
trim start [length|=end]
The optional length parameter gives the length of audio to
output after the start sample and is thus used to trim off the
end of the audio. Alternatively, an absolute end location can
be given by preceding it with an equals sign. Using a value of
0 for the start parameter will allow trimming off the end only.
No, you have to calculate the length if you want to use sox. You could also use ffmpeg instead which has atrim filter that supports start/end times.

Convert String to Date in Informix DB

I need to Convert a string say '12/12/2013 14:30:56.583' to be converted in Date Format like 2013-12-12 14:30:56.583 in Informix database.
I Used following function
to_date('12/12/2013 14:30:56.583',"%d/%m/%Y %H:%M:%S.")
But its not accepting Milliseconds , Milliseconds are important to the resulting value.
The database version is important. The behaviour of %F was recently (11.70.xC8 and 12.10.xC2) changed. In previous versions the "." dot must probably be omitted as well as the "n" qualifier.
Regards
If you check the manual you will see is missing the milliseconds at the string format.
source: http://www-01.ibm.com/support/knowledgecenter/api/content/SSGU8G_12.1.0/com.ibm.sqls.doc/ids_sqs_1542.htm
%S Second as a 2-digit integer (00 through 61). The second value can
be up to 61 (instead of 59) to allow for the occasional leap second
and double leap second.
%Fn The value of the fraction of a second, with precision specified by
the unsigned integer n. The default value of n is 2; the range of n is
0 ≤ n ≤ 5. This value overrides any width or precision that is
specified between the % and F characters.
So, this probably will work:
to_date('12/12/2013 14:30:56.583',"%d/%m/%Y %H:%M:%S.%F3")
I’m not that familiar with Informix, but I think you may be able to use the standard to_date function to convert the string value to a date and then use an addMilliseconds function to add the milliseconds.
http://pic.dhe.ibm.com/infocenter/informix/v121/index.jsp?topic=%2Fcom.ibm.netpr.doc%2Fids_net_093.htm

Is it possible to represent GPS time on an Arduino?

I have a ubox GPS system that outputs the following on the occurrence of an event:
wnR - GPS week number (two bytes)
towMsR - Time of week in milliseconds (four bytes)
towSubMsR - Millisecond fraction of tow in nanoseconds (four bytes)
It looks like to capture the time of the event in nanoseconds I have to use all eight bytes.
That puts it out of the range of the 16-bit Arduino.
Am I thinking about this correctly?
You can use two unsigned long variables for ms and ns (those won't be negative I presume) see the Reference

NSDateFormatter string with subseconds and timezone

I have banged my head against this for too long now!
I have a string: 2012-09-27T18:00:00.000-04:00
I have a format: [dateFormatter setDateFormat:#"yyyy-MM-dd'T'HH:mm:ss'Z'"];
I get a null result converting the string.
Can someone help with the correct date format?
According to the documentation for NSDateFormatter:
The format string uses the format patterns from the Unicode Technical Standard #35. The version of the standard varies with release of the operating system:
Formatters in OS X v10.8 and iOS 6.0 use [version tr35-25].
Following that link:
s 1..2 12 Second. Use one or two for zero padding.
In other words, s for seconds means only the integral part.
But right underneath that, there's:
S 1..n 3456 Fractional Second - truncates (like other time fields) to the count of letters. (example shows display using pattern SSSS for seconds value 12.34567)
Then, the reason you aren't matching the timezone is that you're quoting the Z, so it matches a literal Z rather than a timezone format.
To match the ISO8601 timezone format you're seeing, the same documentation says you want ZZZZZ.
So, it looks like, at least for 10.8/iOS 6, you want:
[dateFormatter setDateFormat:#"yyyy-MM-dd'T'HH:mm:ss'.'SSSZZZZZ"]
For earlier versions, you've got the links to the docs; you should be able to figure it out now.
Testing this (in Python, to save a few lines of code):
>>> import Cocoa
>>> df = Cocoa.NSDateFormatter.alloc().init()
>>> df.setDateFormat_("yyyy-MM-dd'T'HH:mm:ss'.'SSSZZZZZ")
>>> print df.dateFromString_(2012-09-27T18:00:00.000-04:00')
2012-09-27 22:00:00 +0000