28a21acc65b7739507466c367b0ab4faa4368337
[platform/upstream/libzypp.git] / zypp / base / ProfilingFormater.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/base/ProfilingFormater.cc
10  *
11 */
12
13 #include <sys/time.h>
14
15 #include <iostream>
16 #include <fstream>
17 #include <string>
18
19 #include "zypp/base/Logger.h"
20 #include "zypp/base/LogControl.h"
21 #include "zypp/base/String.h"
22 #include "zypp/Date.h"
23 #include "zypp/PathInfo.h"
24
25
26 #include "zypp/base/ProfilingFormater.h"
27
28 using std::endl;
29
30 ///////////////////////////////////////////////////////////////////
31 namespace zypp
32 { /////////////////////////////////////////////////////////////////
33   ///////////////////////////////////////////////////////////////////
34   namespace base
35   { /////////////////////////////////////////////////////////////////
36
37     ///////////////////////////////////////////////////////////////////
38     // ProfilingFormater
39     ///////////////////////////////////////////////////////////////////
40     
41     std::string ProfilingFormater::format( const std::string & group_r,
42                                                   logger::LogLevel    level_r,
43                                                   const char *        file_r,
44                                                   const char *        func_r,
45                                                   int                 line_r,
46                                                   const std::string & message_r )
47     {
48        struct timeval tp;
49        int rtn;
50        rtn = gettimeofday( &tp, NULL);
51        
52         return str::form( "%ld.%ld [%d] <%d> %s(%s):%d %s",
53                         tp.tv_sec,
54                         tp.tv_usec,
55                         level_r,
56                         getpid(),
57                         /*group_r.c_str(),*/
58                         file_r, func_r, line_r,
59                         message_r.c_str() );
60     }
61     /////////////////////////////////////////////////////////////////
62   } // namespace base
63   ///////////////////////////////////////////////////////////////////
64   /////////////////////////////////////////////////////////////////
65 } // namespace zypp
66 ///////////////////////////////////////////////////////////////////