source: launchers/macosx/I2PLauncher/logger_c.h @ ba853a8c

Last change on this file since ba853a8c was 5304709, checked in by meeh <meeh@…>, 2 years ago

OSX Launcher: general cleanup, responsibility delegation, and fixes

  • Property mode set to 100644
File size: 1.6 KB
Line 
1//
2//  logger_c.h
3//  I2PLauncher
4//
5//  Created by Mikal Villa on 30/09/2018.
6//  Copyright © 2018 The I2P Project. All rights reserved.
7//
8
9#ifndef logger_c_h
10#define logger_c_h
11
12#include "Logger.h"
13#include "LoggerWorker.hpp"
14
15/*
16void genericLogger(int loglevel, va_list params) {
17#ifdef __cplusplus
18  const char * paramArray[10];
19  int numParams = 0;
20 
21  NSString* arg = nil;
22  while ((arg = va_arg(params, NSString *))) {
23    paramArray[numParams++] = [arg cStringUsingEncoding:[NSString defaultCStringEncoding]];
24  }
25 
26  switch (loglevel) {
27    case 0:
28      MLOGF(ANNOYING) << params;
29      break;
30    case 1:
31      MLOGF(DEBUG) << params;
32      break;
33    case 2:
34      MLOGF(INFO) << params;
35      break;
36    case 3:
37      MLOGF(WARN) << params;
38      break;
39    default:
40      assert(false);
41  }
42#endif
43}
44 */
45
46inline void MLog(int loglevel, NSString* format, ...)
47{
48#ifdef __cplusplus
49 
50  va_list vargs;
51  va_start(vargs, format);
52  NSString* formattedMessage = [[NSString alloc] initWithFormat:format arguments:vargs];
53  va_end(vargs);
54 
55  NSString* message = formattedMessage;
56 
57  switch (loglevel) {
58    case 0:
59      MLOG(ANNOYING) << [message UTF8String];
60      break;
61    case 1:
62      MLOG(DEBUG) << [message UTF8String];
63      break;
64    case 2:
65      MLOG(INFO) << [message UTF8String];
66      break;
67    case 3:
68      MLOG(WARN) << [message UTF8String];
69      break;
70    case 4:
71      MLOG(ERROR) << [message UTF8String];
72      break;
73    default:
74#if DEBUG
75      assert(false);
76#else
77      return;
78#endif
79  }
80 
81#endif
82}
83
84
85
86#define MMLog(format_string,...) ((MLog(1, [NSString stringWithFormat:format_string,##__VA_ARGS__])))
87
88#endif /* logger_c_h */
Note: See TracBrowser for help on using the repository browser.