s502 assembler
A very simple assembler for the 6502 line of processors written in C
Macros | Functions
logging.h File Reference

logging and fancy-printing More...

#include <stdio.h>

Go to the source code of this file.

Macros

#define LOG(LVL, ...)   if (logging_level(0)>=(LVL)) {printf("\e[33mLOG:\e[39m\t"); printf(__VA_ARGS__);}
 logging macro - works like printf More...
 
#define LOGDO(LVL, x)   if(logging_level(0) >= (LVL)) {x;};
 Conditional macro. Wraps contents into a conditional based on log level. More...
 
#define ERROR(...)   {printf("\e[41mERROR\e[49m:\t"); printf(__VA_ARGS__);}
 Fancy-print an error (cause of faliure). Works like printf. More...
 
#define FAIL(...)   {printf("\e[31mFAIL:\e[39m\t"); printf(__VA_ARGS__);}
 Fancy-print a fail (failed step). Works like printf. More...
 

Functions

int logging_level (int setlevel)
 pseudo-global accessor More...
 

Detailed Description

logging and fancy-printing

Contains conditional logging macros and fancy-print printf wrappers

Definition in file logging.h.

Macro Definition Documentation

◆ ERROR

#define ERROR (   ...)    {printf("\e[41mERROR\e[49m:\t"); printf(__VA_ARGS__);}

Fancy-print an error (cause of faliure). Works like printf.

Definition at line 40 of file logging.h.

◆ FAIL

#define FAIL (   ...)    {printf("\e[31mFAIL:\e[39m\t"); printf(__VA_ARGS__);}

Fancy-print a fail (failed step). Works like printf.

Definition at line 45 of file logging.h.

◆ LOG

#define LOG (   LVL,
  ... 
)    if (logging_level(0)>=(LVL)) {printf("\e[33mLOG:\e[39m\t"); printf(__VA_ARGS__);}

logging macro - works like printf

Parameters
LVLminimum log level

Macro to fancy-print using printf.
Can be used like a printf.
Only prints if log level is set high enough

Definition at line 28 of file logging.h.

◆ LOGDO

#define LOGDO (   LVL,
 
)    if(logging_level(0) >= (LVL)) {x;};

Conditional macro. Wraps contents into a conditional based on log level.

Parameters
LVLminimum log level
xstatement to run conditionally

Definition at line 35 of file logging.h.

Function Documentation

◆ logging_level()

int logging_level ( int  setlevel)

pseudo-global accessor

Parameters
setlevelnew level to set log level to or 0 to don't change
Returns
current log level

Definition at line 6 of file logging.c.

6  {
7  static int current;
8  if (current == 0) {
9  current = 1;
10  }
11  if (level == 0) return current;
12  return current = level;
13 }

Referenced by main(), and state_parse_commandline().