Imported Upstream version 16.5.0
[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       gettimeofday( &tp, NULL);
50
51       return str::form( "%ld.%ld [%d] <%d> %s(%s):%d %s",
52                         tp.tv_sec,
53                         tp.tv_usec,
54                         level_r,
55                         getpid(),
56                         /*group_r.c_str(),*/
57                         file_r, func_r, line_r,
58                         message_r.c_str() );
59     }
60     /////////////////////////////////////////////////////////////////
61   } // namespace base
62   ///////////////////////////////////////////////////////////////////
63   /////////////////////////////////////////////////////////////////
64 } // namespace zypp
65 ///////////////////////////////////////////////////////////////////