2020年4月13日 星期一

C 語言 - Linux System Log

Linux - System Log

    Linux 當事件發生會產生 log,通常會存在 /var/log 底下。優先度如下。
  •     debug
  •     info
  •     notice
  •     warning
  •     err
  •     crit
  •     alert
  •     emerg/panic

C 實作 - void syslog(int priority, const char *format, ...)

    #include<stdio.h>
    #include<stdlib.h>
    #include<syslog.h> 
    syslog(LOG_INFO, "hello %s", "woring");
    syslog(LOG_ERR,  "hello %s", "test");
底下為參數 int priority
LOG_USER : A miscellaneous user process
LOG_MAIL : Mail
LOG_DAEMON : A miscellaneous system daemon
LOG_AUTH : Security (authorization)
LOG_SYSLOG : Syslog
LOG_LPR : Central printer
LOG_NEWS : Network news (e.g. Usenet)
LOG_UUCP : UUCP
LOG_CRON : Cron and At
LOG_AUTHPRIV : Private security (authorization)
LOG_FTP : Ftp server
LOG_LOCAL(0~7) : Locally defined

參考資料 :
https://ithelp.ithome.com.tw/articles/10159084
http://yu-minspace.blogspot.com/2007/09/linux-syslogd-openlogsyslogdsyslog.html

Related Posts:

  • BCB OLE操作EXCEL(3)在用 OLE 操作 Excel 時 有可能會遇到剪貼簿裡的資料過大 導致關閉 Excel 時跳出視窗警告 "是否放棄剪貼簿裡的資料" 要避開的話通常會用關閉 DisplayAlert 的方法來避免 但我常常失敗,原因不明。 所以給失敗的朋友另一個辦法 在 Excel 關閉前複製一格 避免剪貼簿裡資料過多跳出視窗 void __fastcall Excel::Close_2(){ Exc.Range = Exc.WorkSheet.… Read More
  • C 語言 - struct array 初始化 ( Initializing array of structures ) 初始化 struct array struct student { char* name; int grade; int id; }; 1. 依照當初宣告的順序 struct student myStudents[] = { {"Henry", 3, 1}, {"Marry", 3, 2} }; 1. 依照當初宣告的名子 … Read More
  • C 語言 - size_t 及各個常見類型 typedef unsigned int size_t // 通常定義在 stddef.h int8 : -128 ~ 127 int16 : -32768 ~ 32767 int32 : -2147483648 ~ 2147483647 int64 : -9223372036854775808 ~ 9223372036854775807 uint8 : … Read More
  • C 語言 - warning: left shift count >= width of type warning: left shift count >= width of type     一般來說,就是 shift 的 bit 大於資料型態的 bit 數。但有時使用 unsigned long 仍然會出錯,因為 unsigned long 會依照系統的不同,有時是 32 bit 有時是 64 bit,所以這時用 unsigned long long 較為安全 ( 保證 64 bit… Read More
  • BCB OLE操作EXCEL(2) BCB 操作 EXCEL、WORD ( OLE的應用 ) 有時候再操作 EXCEL 和 WORD 的時候,有可能會要應用到 MultiProcess 的概念 但真正需要的地方很少,我自己是用偷懶的方式來避開, 因為互相搶奪導致資料錯誤出現的機率微乎其微。 下面介紹一些我常碰到的錯誤 bool __fastcall JunYe_Word::getDataTable(int index){ Variant Range; bool… Read More

0 意見:

張貼留言

Popular Posts