Skip to content

Commit

Permalink
Merge pull request #18 from atsign-foundation/hamdaan-at-logger
Browse files Browse the repository at this point in the history
feat: add Verbose Logging Utility
  • Loading branch information
HamdaanAliQuatil authored Jun 30, 2023
2 parents 2edec6f + 3374c21 commit c352fc8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
url = https://github.com/espressif/esp-idf.git
[submodule "deps/Arduino-CMake-Toolchain"]
path = deps/Arduino-CMake-Toolchain
url = https://github.com/a9183756-gh/Arduino-CMake-Toolchain
url = https://github.com/a9183756-gh/Arduino-CMake-Toolchain.git
9 changes: 9 additions & 0 deletions include/at_client/at_logger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef ATLOGGER_H
#define ATLOGGER_H

#include <stddef.h>

int atlogger_log(const char *title, const char *message);
int atlogger_logx(const char *title, const unsigned char *bytes, size_t byteslen);

#endif // ATLOGGER_H
20 changes: 20 additions & 0 deletions src/at_client/at_logger.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "at_client/at_logger.h"
#include <stdio.h>

void printx(const unsigned char *bytes, size_t byteslen) {
for (size_t i = 0; i < byteslen; i++) {
printf("%02x ", bytes[i]);
}
printf("\n");
}

int atlogger_log(const char *title, const char *message) {
printf("%s | %s:\n", title, message);
return 0;
}

int atlogger_logx(const char *title, const unsigned char *bytes, size_t byteslen) {
printf("%s | ", title);
printx(bytes, byteslen);
return 0;
}

0 comments on commit c352fc8

Please sign in to comment.