Language

The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.15

How to format profiling time stamp messages

Carsten Driesner and Andre Fischer, last change on August 2nd, 2001

Introduction

Each use of the macros RTL_LOGFILE_CONTEXT_AUTHOR, RTL_LOGFILE_CONTEXT_TRACE<n>, and RTL_LOGFILE_TRACE_AUTHOR<n> writes a time stamp into a logfile that can be parsed by post-processing scripts. This works only if the text that is given as arguments to the macros follows certain rules.

The next section describes the overall format of the time stamps written by the macros. The format of the text passed as arguments to the macros is described int the third section.

Overall time stamp format

Each time stamp written by one of the macros RTL_LOGFILE_CONTEXT_AUTHOR, RTL_LOGFILE_CONTEXT_TRACE<n>, and RTL_LOGFILE_TRACE_AUTHOR<n> has the format

%d %d %c %s : %s

with the following arguments:

  1. Time in milliseconds after the first time stamp. This implies that the first time stamp has always a value of 0 in this field. To convert the relative times into absolute ones or ones that are relative to the application start you can evaluate the first line in the log-file which is described below.

  2. Id of the thread from which the time stamp has been emitted. The process id can be determined from the name of the log-file.

  3. A character the classifies the time steps into three classes:

  1. An { indicates the beginning of a function or other scope.

  2. An } indicates the end of a function or other scope.

  3. An | indicates a message from within a scope or without a scope.

  1. Name or description of a function or other scope. This name is used to group beginnings and ends of a scope together. If RTL_LOGFILE_TRACE_AUTHOR<n> is used instead of RTL_LOGFILE_CONTEXT_TRACE<n> then this field remains empty.

  2. Arbitrary message written by RTL_LOGFILE_TRACE_AUTHOR<n> and RTL_LOGFILE_CONTEXT_TRACE<n>. If RTL_LOGFILE_CONTEXT_AUTHOR is used instead then this field remains empty.

Note that the dividing colon between the last two fields is written even if one of them remains empty.

As you can see, you can only specify the content of the last two fields. The format that they may have is described in the following section.

Admissable format of scope names and messages

This section focuses on the format of the last two fields of a time stamp. The first one should have format

%s (%s) %s

with the following arguments:

  1. Module name. This will be strings like sfx2 or desktop.

  2. Sun id with prefixed shortcut of responsible developer. That would be cd100003 or af119097 for the authors. Use the Sun id of the project owner, if you have no Sun id.

  3. Fully qualified function name with leading double colon. Add a simplified signature only if that is necessary to distinguish it from other functions with the same name. The function name starts with the complete namespace, the class name (if it is really a method) and finally the actual function name.

The three fields are separated by singles spaces.

The second argument may have any format you like with two constraints:

  1. It may not contain a newline character.

  2. If it starts with an opening or a closing curly bracket then it has a meaning similar to the third field of the overall format: it describes the beginning or end of a scope. You can define a logical scope with this format even though you don't have an analog physical representation and don't want to introduce a new scope for it.

Use RTL_LOGFILE_CONTEXT_AUTHOR<n> if possible to automatically write the fields described above with every time stamp emitted from the context. If that is not possible or usefull then start the message field with a string that has the format described above. Use your common sense to fill in the second and fourth field. Divide that string with a colon surrounded by spaces from the actual message string.

Examples

The following pseudo code uses a context to write time stamps at the beginning and end of scopes in the implicit form and the explicit one that uses the message string to indicate the scope boundaries.

void ::Desktop::OpenStartupscreen (arguments)

{

RTL_LOGFILE_CONTEXT_AUTHOR (aInstance, „desktop“, „cd100003“, „::Desktop::OpenStartupscreen“);

...

RTL_LOGFILE_CONTEXT_TRACE (aInstance, „{ lengthy calculation“);

for (...)

{

do something

}

RTL_LOGFILE_CONTEXT_TRACE (aInstance, „} lengthy calculation“);

}

It generate time stamps like these:

001234 11 { desktop (cd100003) ::Desktop::OpenStartupscreen

002345 11 | desktop (cd100003) ::Desktop::OpenStartupscreen : { lengthy calculation

003456 11 | desktop (cd100003) ::Desktop::OpenStartupscreen : } lengthy calculation

004567 11 } desktop (cd100003) ::Desktop::OpenStartupscreen



This pseudo code uses the context free version:

void ::Desktop::CloseStartupscreen

{

...

RTL_LOGFILE_TRACE_AUTHOR („desktop“, „cd100003“, „::Desktop::CloseStartupscreen : Startup finished“);

}

It's output might look like this:

099999 11 | desktop (cd100003) ::Desktop::CloseStartupscreen : Startup finished



Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache, OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. The Apache feather logo is a trademark of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.