1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
13 #include <anna/core/core.hpp>
15 #include <anna/app/Application.hpp>
17 class Test : public app::Application {
21 void initialize () throw (RuntimeException);
24 void run () throw (RuntimeException);
29 int main (int argc, const char** argv)
31 CommandLine& commandLine (CommandLine::instantiate ());
35 commandLine.initialize (argv, argc);
36 commandLine.verify ();
38 if (commandLine.exists ("t"))
39 Logger::setLevel (Logger::asLevel (commandLine.getValue ("t")));
41 Logger::initialize ("testfunctions", new TraceWriter ("file.trace", 2048000));
45 catch (Exception& ex) {
46 cout << ex.asString () << endl;
53 app::Application ("testfunctions", "Checking trace system", "1.0")
55 CommandLine& commandLine (CommandLine::instantiate ());
57 commandLine.add ("s", CommandLine::Argument::Mandatory, "String");
58 commandLine.add ("n", CommandLine::Argument::Mandatory, "Number of loops");
59 commandLine.add ("t", CommandLine::Argument::Optional, "Initial trace level");
62 void Test::initialize ()
63 throw (RuntimeException)
65 CommandLine& commandLine (CommandLine::instantiate ());
67 if (commandLine.exists ("t"))
68 Logger::setLevel (Logger::asLevel (commandLine.getValue ("t")));
72 throw (RuntimeException)
74 CommandLine& commandLine (CommandLine::instantiate ());
76 cout << "Second: " << functions::second () << endl;
77 cout << "MilliSecond: " << functions::millisecond () << endl << endl;
79 string str (commandLine.getValue ("s"));
80 int n (commandLine.getIntegerValue ("n"));
82 Logger::Level level = Logger::getLevel ();
84 for (int i = 0; i < n; i ++) {
86 Logger::write (level, "string", str.c_str (), ANNA_FILE_LOCATION);
88 Logger::write (level, "level", (int) level, ANNA_FILE_LOCATION);
90 level = Logger::Level ((int) level + 1);
92 if (level >= Logger::Local0)
93 level = Logger::Emergency;
94 else if (level > Logger::Debug)
95 level = Logger::Local0;