New Classes for Debug, Info and Error Messages Thomas Kuhr Offline Week 15/09/2004.

Slides:



Advertisements
Similar presentations
11-Jun-14 The assert statement. 2 About the assert statement The purpose of the assert statement is to give you a way to catch program errors early The.
Advertisements

1 Input/Output and Debugging  How to use IO Streams  How to debug programs  Help on coursework.
1 Input/Output and Debugging  How to use IO Streams  How to debug programs.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
Chapter 7: User-Defined Functions II
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
CMSC 2021 C++ I/O and Other Topics. CMSC 2022 Using C++ Stream I/O Default input stream is called cin Default output stream is called cout Use the extraction.
File streams Chapter , ,
Overview creating your own functions calling your own functions.
Chapter 6. 2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single Value Pass by Reference Variable Scope.
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 19 - The Preprocessor Outline 19.1 Introduction 19.2 The #include Preprocessor Directive 19.3.
Input and Output in Console Mode UNIVERSITY OF THE PUNJAB (GUJRANWALA CAMPUS) ADNAN BABAR MT14028 CR
Week 3 Part I Kyle Dewey. Overview Odds & Ends Constants Errors Functions Expressions versus statements.
Classes Representing Non-Trivial Objects. Problem Write a program that reads a temperature (either Fahrenheit or Celsius), and displays that same temperature.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
chap13 Chapter 13 Programming in the Large.
Chapter 9 Defining New Types. Objectives Explore the use of member functions when creating a struct. Introduce some of the concepts behind object-oriented.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
Chapter 13 Programming in the Large Dr. Jiung-yao Huang Dept. Comm. Eng. Nat. Chung Cheng Univ. TA: 鄭筱親 陳昱豪.
1 Programs Composed of Several Functions Syntax Templates Legal C++ Identifiers Assigning Values to Variables Declaring Named Constants String Concatenation.
Workbook and User Settings SAP BusinessObjects Analysis, edition for Microsoft Office v1.0.
Defining and Converting Data Copyright Kip Irvine, 2003 Last Update: 11/4/2003.
Introduction to Exception Handling and Defensive Programming.
C Hints and Tips The preprocessor and other fun toys.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
1 Advanced Issues on Classes Part 3 Reference variables (Tapestry pp.581, Horton 176 – 178) Const-reference variables (Horton 176 – 178) object sharing:
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
Introduction to C++ Version 1.1. Topics C++ Structure Primitive Data Types I/O Casting Strings Control Flow.
User Defined Functions Chapter 7 2 Chapter Topics Void Functions Without Parameters Void Functions With Parameters Reference Parameters Value and Reference.
Classes Representing Non-Trivial Objects. Problem Write a program that reads a temperature (either Fahrenheit or Celsius), and displays that same temperature.
Object Oriented Programming (OOP) Lecture No. 11.
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessing Lecture 12 April 7, 2005.
C++ Programming Lecture 11 Functions – Part III By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
CMSC 202 Text File I/O. Aug 8, Text Files and Binary Files Files that are designed to be read by human beings, and that can be read or written with.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Debugging Computer Networks Sep. 26, 2007 Seunghwan Hong.
12/14/2015 Concept of Test Driven Development applied to Embedded Systems M. Smith University of Calgary, Canada 1 Automated Testing Environment Concepts.
Functions Math library functions Function definition Function invocation Argument passing Scope of an variable Programming 1 DCT 1033.
EIToolkit stub doc. main.cpp file int main(int argc, char* argv[]) { EIProperties::UseStandards(); // create the stub ExampleStub stub; stub.Start();
1 What is a Named Constant? A named constant is a location in memory that we can refer to by an identifier, and in which a data value that cannot be changed.
CHAPTER 2 PART #3 C++ INPUT / OUTPUT 1 st Semester King Saud University College of Applied studies and Community Service CSC1101 By: Fatimah.
Error Handling Tonga Institute of Higher Education.
THE PREPROCESSOR
The Preprocessor Directives Introduction Preprocessing – Occurs before program compiled Inclusion of external files Definition of symbolic constants.
Chapter – 8 Software Tools.
Week 4 - Monday.  What did we talk about last time?  Precedence  Selection statements  Loops  Lab 3.
Exception Handling How to handle the runtime errors.
AliRoot Classes for access to Calibration and Alignment objects Magali Gruwé CERN PH/AIP ALICE Offline Meeting February 17 th 2005 To be presented to detector.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
Chapter 4 Strings and Screen I/O. Objectives Define strings and literals. Explain classes and objects. Use the string class to store strings. Perform.
Functions Input and output Lecture 2. Constants #define – is a preprocessor directive Most common use.
Chapter 7: User-Defined Functions II
Topic Pre-processor cout To output a message.
Chapter 6 CS 3370 – C++ Functions.
Logger, Assert and Invariants
Testing and Debugging.
Week 4 - Monday CS222.
User-Defined Functions
User Defined Functions
Automated Testing Environment
CISC101 Reminders Assn 3 due tomorrow, 7pm.
CS150 Introduction to Computer Science 1
Basic Debugging (compilation)
Chapter 1 c++ structure C++ Input / Output
Presentation transcript:

New Classes for Debug, Info and Error Messages Thomas Kuhr Offline Week 15/09/2004

2 Requirements  During Development: -Need detailed debug output for certain class / module  During production: -Keep log files small -Only relevant messages  Don’t want to miss important messages among thousands of unimportant messages -No debug output

3 Current Situation Debug output with cout/cerr, printf, TObject::Info, … Debug flag fDebug, Set/GetDebug() → Need access to object  Difficult to set Possible improvements:  Dedicated output method for debug information  Common and flexible way of (debug) output steering  Setting of debug level by class / module, not by object

4 New Scheme Steering of output by the user:  AliLog class Macro Aliroot prompt.rootrc file Output messages put into the detector code by the developers:  AliError macros

5 AliLog Class (Debug) output managed by singleton class AliLog Access via static methods Detailed steering of output level: EnableDebug(Bool_t enabled); SetGlobalLog/DebugLevel(Int_t level); SetModuleDebugLevel(const char* module, Int_t level); SetClassDebugLevel(const char* class, Int_t level); ROOT TError messages included: SetHandleRootMessages(Bool_t on);

6 AliLog Class (continued) Steering of output streams: SetStandardOutput(EType type); SetErrorOutput(EType type); SetFileOutput(EType type, const char* fileName); Steering of displayed information: SetPrintType(EType type, Bool_t on); SetPrintModule(EType type, Bool_t on); SetPrintScope(EType type, Bool_t on); SetPrintLocation(EType type, Bool_t on); All options can be steered via.rootrc

7 AliError Macros Preprocessor macros : AliDebug(level, “message”); AliInfo/Warning/Error/Fatal(“…”);  Automatically get: –Module name –Class name (via virt. meth. ClassName()) –Function name (not on all platforms) –Source file name –Source line number  Complete removal of debug messages possible with compiler flag

8 AliError Macros (continued) Inside static class method: AliErrorClass(“message”); (Root: ::Error(…); ) Outside of classes: AliErrorGeneral(“scope”, “message”); Message parameters: AliError(Form(“i=%d”, i)); (Root: Error(“…”, “i=%d”, i); )

9 AliError Macros (continued) C++ stream syntax: AliErrorStream() << “message” << object; Redirection of stdout/stderr: ToAliError( Function(); object.Print(); );

10 Migration to New Scheme Replace Root Error by AliError, etc. Replace printf, cout, cerr by AliDebug, AliInfo, etc. Exception: Print method –Print to stdout →Consistent with Root →Redirection to different message types possible –Reminder: Use right signature: void Print(Option_t* opt=““) const; Remove Get/SetDebug(), fDebug, use AliDebug instead Use appropriate type of message

11 When to Use What Kind of Message? FatalThe program can not be continued under these conditions. ErrorThere is something wrong that has to be fixed. WarningThere might be something wrong. Don’t just ignore it unless you understand the warning. InfoInformation about successful operations, e.g. number of found clusters/tracks DebugInformation for debugging and development: -Program flow -Intermediate results -Detailed trace of variable values -…

12 Examples Error(“method”, “…”); →AliError(“…”); Info(“method”, “i=%d”, i); →AliInfo(Form(“i=%d”, i)); →AliDebug(1, Form(“i=%d”, i)); if (GetDebug()>1) Info(“method”, “…”); →AliDebug(2, “…”); SetDebug(2); fDebug=3; →

13 Examples printf(“data=%f\n”, data); →AliDebug(3, Form(“data=%f”, data)); cerr << i << endl; →AliDebug(5, Form(“%d”, i)); cout << object; →AliDebugStream(4) << object; Warning(“method”, “…”); object.Print(); →AliWarning(“…”); ToAliWarning(object.Print();); void PrintStatus(Option_t*); →void Print(Option_t* opt=“”) const;

14 Scenario for Production Disable debug output with compiler flag ( -D LOG_NO_DEBUG ) Send error, warning and info messages to a log file Send rest (printf, cout, cerr) to /dev/null Read log file: –Error messages  Fix code –Warning messages  Explain and accept or fix code –No error or warning messages  Assume proper execution

15 Summary No consistent treatment of debug messages so far No switch “debug mode” ↔ “production mode” AliLog class and AliError macros provide: –A dedicated and common method for debug output –Detailed information automatically available –Easy and flexible steering of debug levels –Easy and flexible steering of output streams –Integration of root messages –Removal of debug output possible with compiler flag (production mode) –No Set/GetDebug() methods needed any more  Migrate to new scheme