Lux Logging System - LuxRender Wiki
Luxrender GPL Physically Based Renderer

Lux Logging System

Personal tools

From LuxRender Wiki

Jump to: navigation, search

Lux has a logging system in place to log messages to the console. This page will give brief of this logging system and how to use it. Further developers are encouraged to use these instead of using printf or cout in the code. This will help the source code and log messages consistent. Please keep in mind all these logging routines either log the message to stdout or stderr currently. They have no support to log into a file or persistent medium. Lux error handling routines are declared in he file core\api.h and their definition can be found in the file core\api.cpp All of the error handlers have the following format

typedef void (*LuxErrorHandler)(int code, int severity, const char *msg); More information regarding the code and severity will be given below in this chapter.



The error handling Routines


  • extern void luxErrorHandler(LuxErrorHandler handler)

This is the setter routine for error handling. The job of this function is to set LuxErrorHandler. This does nothing else. So if we want to change the error handler at any point of time then it is advisable to call this routine as the logging format may go some change in future.

  • extern void luxErrorAbort(int code, int severity, const char *message)

This routine will log the error and Abort if the severity level is anything other than LUX_INFO (severity != LUX_INFO). The exit code will the the code value passed to this function. So calling this function with a severity level of LUX_INFO is same as calling the function luxErrorPrint. In fact this function internally calls luxErrorPrint.

  • extern void luxErrorIgnore(int code, int severity, const char *message)

This function is the setter method to est the value of the luxLastError with the value passed with code. This function does not print to the console.

  • extern void luxErrorPrint(int code, int severity, const char *message)

This function has two jobs first it will set the luxLastError value with the code passed to it Then it updates the stderr with the message of format given below: [Lux <Local time> <Severity level> : ] <User message passed to this function>



Error Codes


The error codes currently are classified as follows

1 - 10     System and File errors
11 - 20     Program Limitations
21 - 40     State Errors
41 - 60     Parameter and Protocol Errors
61 - 80     Execution Errors
  • Error Name LUX_NOERROR

Value 0

Description This signifies no error.

  • Error Name LUX_NOMEM

Value 1

Description

Out of memory

  • Error Name LUX_SYSTEM

Value 2

Description

Miscellaneous system error

  • Error Name LUX_NOFILE

Value 3

Description

File nonexistant

  • Error Name LUX_BADFILE

Value 4

Description

Bad file format

  • Error Name LUX_BADVERSION

Value 5

Description

File version mismatch

  • Error Name LUX_DISKFULL

Value 6

Description

Target disk is full

  • Error Name LUX_UNIMPLEMENT

Value 12

Description

Unimplemented feature

  • Error Name LUX_LIMIT

Value 13

Description

Arbitrary program limit

  • Error Name LUX_BUG

Value 14

Description

Probably a bug in renderer

  • Error Name LUX_NOTSTARTED

Value 23

Description

luxInit() not called

  • Error Name LUX_NESTING

Value 24

Description

Bad begin-end nesting

  • Error Name LUX_NOTOPTIONS

Value 25

Description

Invalid state for options

  • Error Name LUX_NOTATTRIBS

Value 26

Description

Invalid state for attributes

  • Error Name LUX_NOTPRIMS

Value 27

Description

Invalid state for primitives

  • Error Name LUX_ILLSTATE

Value 28

Description

Other invalid state

  • Error Name LUX_BADMOTION

Value 29

Description

Badly formed motion block

  • Error Name LUX_BADSOLID

Value 30

Description

Badly formed solid block

  • Error Name LUX_BADTOKEN

Value 41

Description

Invalid token for request

  • Error Name LUX_RANGE

Value 42

Description

Parameter out of range

  • Error Name LUX_CONSISTENCY

Value 43

Description

Parameters inconsistent

  • Error Name LUX_BADHANDLE

Value 44

Description

Bad object/light handle

  • Error Name LUX_NOPLUGIN

Value 45

Description

Can't load requested plugin

  • Error Name LUX_MISSINGDATA

Value 46

Description

Required parameters not provided

  • Error Name LUX_SYNTAX

Value 47

Description

Declare type syntax error

  • Error Name LUX_MATH

Value 61

Description

Zerodivide, noninvert matrix, etc.


Error Severity levels


These levels signify how sever the error is.

  • Name LUX_INFO

Value 0

Description

Rendering stats & other info

  • Name LUX_WARNING

Value 1

Description

Something seems wrong, maybe okay

  • Name LUX_ERROR

Value 2

Description

Problem. Results may be wrong

  • Name LUX_SEVERE

Value 3

Description

So bad you should probably abort


Now we will see how the logging system is initialized and works. First of all mostly in the code these function are not called but the function is called luxError which is of type LuxErrorHandler. And luxLastError is set to LUX_NOERROR. So further when we encounter some error we have to set it. So in the code we have to use these functions.