Ib txoj hauv kev tseem ceeb rau kev kuaj pom qhov ua haujlwm tsis zoo hauv kev siv software twb khiav ntawm tus neeg siv lub koos pij tawj yog khaws cov xwm txheej teev cia - cav. Feem ntau, lawv sau cov ntaub ntawv ntsig txog cov phiaj xwm xaib, nrog rau cov xov xwm tseem ceeb ntawm lub xeev ntawm cov txheej txheem thiab ib puag ncig ntawm lub kaw lus thaum muaj teeb meem loj tsis taus. Koj tuaj yeem tsim lub cav ob qho tib si los ntawm koj tus kheej txoj kev siv thiab siv cov kev pabcuam tshwjxeeb ntawm cov haujlwm ua haujlwm.
Nws yog qhov tsim nyog
- - tus txhais lus los ntawm cov lus siv programming;
- - tejzaum nws lub Windows Platform SDK;
- - tejzaum nws kev tsim kho pob rau glibc.
Cov Lus Qhia
Kauj ruam 1
Txheeb xyuas cov ntsiab lus ntawm kev siv thiab ua kom muaj raws li qhov yuav tsum tau tsim rau hauv kab ke, tsim ua lossis tsev qiv ntawv uas yuav ua lub cav. Teb cov lus nug hais txog qhov chaw ua haujlwm lossis chaw ua haujlwm twg nws yuav tsum ua haujlwm hauv, nws qib API yuav yog.
Kauj ruam 2
Raws li cov cim haujlwm ua haujlwm tau thiab qib API muab, tsim qauv rau kev nkag lub cav. Pib siv nws txoj haujlwm.
Kauj ruam 3
Qhov kev xaiv yooj yim tshaj plaws rau kev sau cia yog mus sau cov ntaub ntawv hauv ib qho chaw uas tau txiav txim siab los ntawm daim ntawv thov kev teeb tsa, thiab tom qab ntawd sau cov ntaub ntawv hauv ib hom ntawv twg rau lawv. Siv C tus qauv hauv tsev qiv ntawv (fopen, fclose, fwrite), C ++ cov tsev qiv ntawv txheem khoom (ntawm cov dej), cov chav kawm sib xws (xws li CFile, QFile), lossis operating system API haujlwm (CreateFile, WriteFile ntawm Windows).
Kauj ruam 4
Siv kev txiav txim siab siv cav syslog API ntawm UNIX-tshaj cov kev khiav haujlwm. Lub luag haujlwm ntawm syslog API tau tshaj tawm nyob rau hauv syslog.h header file. Txuas nws rau qhov chaw raug nyob rau hauv qhov chaw ntawm koj qhov project.
Kauj ruam 5
Txuas mus rau syslog kev pabcuam siv qhov qhib hu ua haujlwm hu. Raws li cov kev txwv, dhau nws tus taw rau cov hlua uas muaj lub cim ntawm daim ntawv thov lossis cov khoom siv uas yuav sau, xaiv tus chij thiab daim npog qhov ncauj ntawm cov xwm txheej kom dhau mus rau lub cav. Siv hu rau syslog thiab vsyslog haujlwm kom ntxiv cov khoom rau lub cav. Hu rau qhov chaw kaw neeg muaj nuj nqi kom tsis muaj txiaj ntsig. Ib qhov piv txwv yooj yim ntawm syslog code yuav yog: openlog ("prefix", LOG_NDELAY | LOG_CONS | LOG_PID, LOG_LOCAL1); syslog (LOG_INFO, "% s", "Info"); syslog (LOG_NOTICE, "% s", "Ceeb Toom"); closelog (); Nws ua rau pom kev txuas mus rau syslog thaum pib ua daim ntawv thov, thiab txiav tawm thaum kaw.
Kauj Ruam 6
Ntawm Windows operating systems, siv EventLog API ntxiv kev nkag rau cov kab ke hauv lub cev. Hu rau RegisterEventSource kom tau txais cov lus piav qhia sau cia ntawm lub tshuab teev tseg. Siv qhov kev kov no thaum hu xov tooj rau ReportEvent txoj haujlwm uas sau rau hauv lub cav. Thaum ua tiav, hu rau DeregisterEventSource kom kaw qhov kev sib txuas thiab tso cov khoom siv los ntawm RegisterEventSource. Cov piv txwv yooj yim ntawm kev ua haujlwm nrog EventLog tej zaum yuav yog: HANDLE h =:: RegisterEventSource (NULL, "AnySource"); ASSERT (h! = NULL);:: ReportEvent (h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 3, 0, "Text1Text2Text3", NULL);:: DeregisterEventSource (h); Raws li nrog syslog, nws ua rau muaj kev nkag siab hu rau RegisterEventSource thaum pib thiab DeregisterEventSource ntawm daim ntawv thov kaw.