-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update documentation and install instructions
Showing
7 changed files
with
175 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Error functions | ||
### Checking the error code | ||
When a function fails, depending on the return value, you may receive a `false` | ||
or a `NULL` return. To learn what went wrong and why the function failed, you can | ||
use check the `errno`: | ||
```c | ||
#include <errno.h> | ||
... | ||
if(!ctorm_app_run(app, argv[1])){ | ||
if(errno == BadAddress) | ||
ctorm_fail("you specified an invalid address"); | ||
else | ||
ctorm_fail("something else went wrong: %d", errno); | ||
return EXIT_FAILURE; | ||
} | ||
``` | ||
See [errors.h](../inc/errors.h) for the full list of error codes. | ||
|
||
### Getting the error description | ||
To get the string description of an error, you can use `ctorm_geterror`: | ||
```c | ||
if(!ctorm_app_run(app, "0.0.0.0:8080")){ | ||
ctorm_fail("something went wrong: %s", ctorm_geterror()); | ||
return EXIT_FAILURE; | ||
} | ||
``` | ||
Or you can get the description of a specific error code: | ||
```c | ||
ctorm_info("BadAddress: %s", ctorm_geterror_from_code(BadAddress)); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
# Log Functions | ||
ctorm provides a simple, colored logging system for your | ||
# Log Functions | ||
ctorm provides a simple, colored logging system for your | ||
general logging usage. | ||
|
||
### General logging functions | ||
### General logging functions | ||
```c | ||
info("some information"); | ||
warn("there may be something wrong"); | ||
error("PANIC!!"); | ||
ctorm_info("some information"); | ||
ctorm_warn("you better read this"); | ||
ctorm_fail("PANIC!!"); | ||
``` | ||
### Enable/Disable request logging | ||
By default ctorm will log information about every single request | ||
on the console, you can disable/enabled this with the [app configuration](app.md). | ||
By default ctorm will log information about every single request, | ||
you can disable/enabled this with the [app configuration](app.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters