ulogger
athreadsafeloggerwithcoloredoutput
colors.c File Reference
#include "colors.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
Include dependency graph for colors.c:

Go to the source code of this file.

Functions

char * get_ansi_color_scheme (COLORS color)
 returns an ansi color string to be used with printf More...
 
char * format_colored (COLORS color, char *message)
 prefixes a message with the given ANSI color code More...
 
void print_colored (COLORS color, char *message)
 prints message to stdout with the given color More...
 
int write_colored (COLORS color, int file_descriptor, char *message)
 is like print_colored except it writes the data into the given file descriptor More...
 

Function Documentation

◆ format_colored()

char* format_colored ( COLORS  color,
char *  message 
)

prefixes a message with the given ANSI color code

Returns
Success: char pointer containing the message prefixed with the ANSI color code
Failure: NULL pointer
Note
you must free up the allocate memory for the returned vlaue

Definition at line 56 of file colors.c.

Here is the call graph for this function:

◆ get_ansi_color_scheme()

char* get_ansi_color_scheme ( COLORS  color)

returns an ansi color string to be used with printf

Definition at line 26 of file colors.c.

Here is the caller graph for this function:

◆ print_colored()

void print_colored ( COLORS  color,
char *  message 
)

prints message to stdout with the given color

Definition at line 77 of file colors.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_colored()

int write_colored ( COLORS  color,
int  file_descriptor,
char *  message 
)

is like print_colored except it writes the data into the given file descriptor

Returns
Success: 0
Failure: 1

Definition at line 86 of file colors.c.

Here is the call graph for this function: