examples/core/logger/main.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
3 
4  This file is part of the TerraLib - a Framework for building GIS enabled applications.
5 
6  TerraLib is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License,
9  or (at your option) any later version.
10 
11  TerraLib is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with TerraLib. See COPYING. If not, write to
18  TerraLib Team at <terralib-team@terralib.org>.
19  */
20 
21 /*!
22  \file terralib/examples/core/logger/main.cpp
23 
24  \brief Examples for the Terralib Logger Module
25 
26  \author Matheus Cavassan Zaglia
27 */
28 
29 // TerraLib
32 
33 #define MY_LOG_WARN(message) TE_CORE_LOG_WARN("mylogger", message)
34 #define MY_LOG_FATAL(message) TE_CORE_LOG_FATAL("mylogger", message)
35 #define MY_LOG_DEBUG(message) TE_CORE_LOG_DEBUG("mylogger", message)
36 
37 int main(int argc, char *argv[])
38 {
39 
40  //Initializing terralib default logger
41  TE_INIT_DEFAULT_LOGGER("logs/terralib.log");
42 
43  //Adding a logger from a configuration file.
44  TE_ADD_LOGGER_FROM_FILE(te::core::FindInTerraLibPath("share/terralib/config/te-log.ini"));
45 
46  TE_LOG_TRACE("This is a trace log.");
47  TE_CORE_LOG_DEBUG("vp", "Logging config file");
48  TE_LOG_INFO("This is a info log");
49  TE_CORE_LOG_DEBUG("vp", "Logging config file");
50  TE_CORE_LOG_DEBUG("mnt", "Logging config file");
51  TE_LOG_ERROR("This is a error log");
52  TE_CORE_LOG_DEBUG("attributefill", "Logging config file");
53 
54  //Adding a new logger without configuration file.
55  TE_ADD_LOGGER("mylogger", "log/mylogs.log", "[%TimeStamp%]{%ThreadID%} %Process%(%ProcessID%) <%Severity%>: %Message%");
56 
57  MY_LOG_WARN("This is a warning log.");
58  MY_LOG_FATAL("This is a fatal log.");
59  TE_LOG_INFO("This is a info log");
60  TE_LOG_ERROR("This is a error log");
61  MY_LOG_DEBUG("This is a debug log.");
62 }
#define TE_ADD_LOGGER_FROM_FILE(filename)
Use this tag to init a logger using a configuration file.
Definition: Logger.h:184
#define TE_CORE_LOG_DEBUG(channel, message)
Use this tag in order to log a message to a specified logger with the DEBUG level.
Definition: Logger.h:225
This file is a wrapper around platform specific include files.
#define TE_LOG_INFO(message)
Use this tag in order to log a message to the TerraLib default logger with the INFO level...
Definition: Logger.h:315
int main(int argc, char *argv[])
#define TE_INIT_DEFAULT_LOGGER(filename)
Use this tag in order to initialize the default TerraLib logger.
Definition: Logger.h:197
#define MY_LOG_DEBUG(message)
#define TE_ADD_LOGGER(name, filename, format)
Use this tag to init a logger using a default implementation without a configuration file...
Definition: Logger.h:168
#define MY_LOG_WARN(message)
This class is designed to manage the log of information in TerraLib.
#define TE_LOG_TRACE(message)
Use this tag in order to log a message to the TerraLib default logger with the TRACE level...
Definition: Logger.h:293
TECOREEXPORT std::string FindInTerraLibPath(const std::string &path)
Returns the path relative to a directory or file in the context of TerraLib.
#define TE_LOG_ERROR(message)
Use this tag in order to log a message to the TerraLib default logger with the ERROR level...
Definition: Logger.h:337
#define MY_LOG_FATAL(message)