 Terima kasih kerana menonton. Semuanya semuanya kembali. Mungkin saya boleh mulakan sekarang. Nama saya Eric, atau Gao Xiang. Saya seorang penerbangan makanan. Pada hari ini, saya akan bercakap tentang logi api. Tapi saya akan modulasi logi sebagai permainan. Sebelum saya mulakan, saya dapat tahu... sesiapa yang bermain permainan ini? Baki Oha? sesiapa? Super Mario? Ya, jadi sesuatu yang sama. Tapi berdua berdua berada di platform NES. Tapi ini adalah satu permainan yang paling susah dalam permainan itu. Jadi permainan terlihat seperti ini. Sebenarnya, Rebid cuba menyelamatkan teman-teman dia. Jadi modulasi ini tentang logi. Jadi pertama, saya juga mahu tanya... berapa banyak penerbangan javascript? Bagus, banyak. Python? Ia masih ada sesuatu. Golong? Java? Okey. Jadi saya akan menyebabkan semua itu nanti. Semoga anda dapat menemukan sesuatu nanti. Bagaimana dengan logi? Saya cuba menyebabkan lagi. Berapa banyak penerbangan javascript pada aplikasi anda? Okey. Berapa banyak penerbangan javascript? Semuanya. Semuanya? Semuanya? Jadi logi adalah sebuah... pertanyaan yang menarik dan pertanyaan yang susah. Kerana... ada banyak penerbangan javascript. Dan logi dapat menjadi... menerbangan atau menerbangan. Dan... bagaimana anda boleh melakukan logi. Mungkin dalam bank anda mahu melakukan logi. Jadi... kebanyakan masa anda perlu memutuskan... apa yang anda mahu melakukan logi. Dan dalam kes api, seperti... bagaimana kita bercakap tentang api web, anda boleh mahu melakukan logi tentang kebanyakan anda. Jika anda menghubungi database, anda boleh mahu melakukan logi tentang... bagaimana kebanyakan anda? Dan... juga kebebasan anda. Jika... apabila salah berlaku, keadaan produsional anda boleh menggunakan logi... untuk membantu anda menerbangan kebanyakan. Dan untuk penerbangan, tentu saja... logi adalah untuk anda menerbangan kebanyakan. Saya rasa... pada masa terakhir, mereka telah menunjukkan... bagaimana anda melakukan logi... dengan reak natif juga. Jadi, mari kita mulakan permainan. Jadi permainan sebenarnya... mempunyai seleksi stage. Ia mempunyai 4 stage, yang adalah screen... green planet, bright planet, blue dan yellow. Dan kemudian, kami akan menerbangan penerbangan. Seperti yang saya mempunyai kepada anda, kami akan memasukkan... bahan seperti... stage. The first stage is JavaScript. But of course, there is no like... which one is easier, which one is harder, it's just mapping. And then the right will be Python. And the blue one will be Golang. And then the yellow one will be GVM. So for each of the top, my goal is... each of the part, my goal is to create a simple... web application. Just have two endpoints. One is... receiving the request, and then return a text. The second one is to return an error. So it's very simple, but along the way, what we want to learn is to... how to use the best practice of vlogging. So let's go to JavaScript first. So JavaScript, as we know, it has two parts. The first part will be browser environment, like here. So basically, I can just open my Chrome debugger. And then... in the console, I can just... just tap in anything, and then it will log for me. This is very simple, because in most of the browser, you already have your console API. And with the console API, you can log a lot of things, not even just text. It can also be a picture. So this can help the front-end developer. I'm sure it will be a good tool for front-end developer, right? And another best thing is if you're using Aglify, and then all the log information will be removed during the Aglify process. So this is very helpful. Another environment is the server environment. So nowadays, most of the developer will use Node.js, and there is also a console. But if you check the difference, there are some methods are missing, but both of them have the info, error, or log method, which is for you to output to... In the browser environment, you will output to your console. In the Node.js environment, you will output to your standard output. And most of the time, you may not only want to output to your standard output. You may want to output to, let's say, a file. And you may want to have multiple output destination. So you may want to use a framework. So in this case, I will choose a framework called vision. And then let's see how does it work. Just a moment. So, the code is on the GitHub and then now I'm starting a Node.js server. For most of the guys, you just run yum.start. Now I'm starting a express server. So let's try to call the tool endpoint I mentioned just now. As you can see, you return me a string here, which is spiky, the robot. This is one of the game corrector inside the game, which is saved after you complete the green planet. There is another one, which is error. Sorry, wrong one. So you will return you error here and if you notice the static code is 500. And let's go back to the server. As you can see here, it has output two of the logging. In this case, I'm just creating two information. One is ID, which is a UUID. So most of the time you may want to have an ID for what you are logging as a reference. And later, when I'm describing the boss, which is the diaper, you will use the ID as a tracing point when you are doing distributed logging. Now I stop the server. And as you can see, there is a log file. And the same thing is logged to the file. So how do we achieve that? The server is very simple. Most of you, I think if you have done Express, this is very familiar with you. But if you notice here, I have a logger, which I have two transport, which is like two output destination. One is to the console, one is to the file. In this case, if I'm getting from the green endpoint, then I will do an info log. If it's error, I will do an error log. So in this case, you can also use the console log which will direct to the standard output. But if you check back the log, the information log is the original information I put in and the level of the log and together the time span. But unfortunately, there is no line number here. So for me, I haven't figured out the way for JavaScript. So if anyone know, please let me know as well. So far so good, right? You can understand, right? So this is very simple. What we have learned, console.log is universal. You can use it on the browser. You can use it as the backend as well. So now we have saved the first corrector, which is a robot. Let's move on to Python. So for Python developers, you will know logging as the standard package, right? And you really want for this package, it's powerful than the JavaScript one because you can do more formatting and you have actually you have more control over it. So in this case, in this case, I create a flask server and then we can do the same thing. Let's switch to the curve. As you can see, the same output has written. This time is that i, which is the dot, the second corrector we are rescuing. So now it's the error page. Same thing, you will output to the console output. There is also a file which contains the same information. So at here beside the logging level plus the information we have added, it also has the line information. This is very helpful for you to debug your application. The server is also very simple. If you know flux, this will be very familiar with you as well. One thing to notice maybe there is a log format which will help you to define your logging information. And another thing I have noticed is that for the handler and the logger because flux itself has the logger you must set both of the level or else it will not log your information to your file. So now we have see another corrector what we have learnt the standard logging package is very good for Python at least compared to JavaScript I think. Ya. So Golang, just now who was the Golang developer? Cool. So does Golang itself standard has a logging framework but it's not very useful, right? Because it doesn't have the level and it doesn't have the other useful information as the others, right? I think Google has come out with this Google Go log, right? Ya. Ya, ya, ya. Ya, ya, ya. Correct, correct. So in this case I'm doing the same thing but I'm choosing the Google Golang logging framework. So let's say how it goes. So the server has studied as well. Let's do the same thing. Now we have saved Jenny, the cat. This is the error. Let's go back to the console. In this in this case the log is not redirect to the standard output. I'm not sure how the Golang framework can doing that because I'm just using the default information maybe some other can help me. So in this case how the Google Golang framework does is for each level of the information it create a file. In this case both your information log and error log will go to your information log file. In this case it also has the timing and your line number plus additional information you want to have here. So how did we achieve that? This will be very familiar to you as well. Basically we are studying a server. We have two handlers. One is the blue handler. One is the error handler. One thing to note here maybe is the Golang. The flush because if you don't flush it doesn't help you to push your logging information to the file. So now we have saved our third friend which is the cat. Actually there is a good blog here. The guy has talked about what is important to log and how the goal logging framework has been becoming better and better. So basically the idea is logging is very important but logging is very hard. Last Java developers. So how many logging frameworks do you think Java has? Anyone still using you tell the logging? Okay. So I'm not going to start over so I will not see which one is the favorite. But I think I'm actually coming from Java world. One of the best thing I can see from here is that the XML configuration because for previous ones most of the time when you want to change your logging to different location or different level you need to change your code. In this case just one XML that means I don't need to change my code. Just by changing the configuration in the logging configuration I can change what I want to log and where I want to log to. And also the level I want to start logging. But one problem I have fun during my personal use is you can only set one file to be logged to. It's very hard for you to like have different level to different files. Yeah. If anyone has found a solution to that please let me know as well. Yes. Yes. But yeah you can have same level different files but I want have different level for different files. Yeah. Yeah. It should be. The concept is that actually the XML level depending on different libraries there are different locus the locus the filter Yeah. Correct. The concept of different locus is that different. Yeah. Correct. That's come to my other question because most of the best practice is you want to have per class per logger. Right. For Java you really I think the standard is you have a private logger equal to your new class logger. Right. But like for some of the framework they already create a default logger for you and my personal how do I say my personal preference will be I will only have one logger helper class rather than each time. Maybe that's the reason the solution So in this case I choose play framework the Java version as an example it needs some loading because it's just compiling and then it's the same thing this time we save really and same thing the 500 status and the error So at here the console also output application In this case Java framework it doesn't only output the logger level and the line number and all that it also help you to log which track is actually using it's actually using in this case So we are using logback in this case this will be the example configuration Yeah So again we have save another team mates So now we have save all of our team mates let's face the boss which is how many of you familiar with diaper So basically it's a distributed logging framework from Google actually it's a paper the link is down step here this is one of the picture from the paper the key idea is just now when we are doing logging we are actually logging from one system but a lot of time like nowadays you are talking about micro services you will have multiple sub applications and there will be dependency from one application to another application So how do you find the linkage between when you are doing a REST call from one application to another one So one of the solution they have come out is with diaper the key idea will be I'm not really a good paper explainer but the key idea is you will have root span R3 basically it model the whole thing as a R3 and then each time you create a new request you will have a tracing ID and then you will append the ID the information as metadata to the next request so that the next request also have the information and then from the UI point of view you will view something like this which means this may be a whole request and then one of the small bar will be another sub request to another system So in this case you will have a lot of information to linkage where you have filled which system has filled rather than debugging individual information each individual system so this is very helpful and because stepper is from Google is not open source a lot of people are doing open source based on the paper so one of the one is from Twitter it's called Dampin and I think nowadays most of people will use this open tracing so I will do a simple example of open tracing so the example is not written by me but the idea is that we have web application actually has 3 end point the first end point is the entry point and then it will call one more another URL on the same server but because it's just as a simulation you can assume this one is calling to another system as well so I will just show you the demo first so basically the open tracing actually has 3 main component the first one is stepper which is the receiver of all your logging information and this is app dash which is for UI display because you want to know like just now the fancy UI you want to see and then for your code you will need to add some code to add the span and tracing ID so let's see this is an example app basically when you click this it's trying to call another end point and then you will try to call another end point so the result will be sorry will trace so this is the trace so basically as you can see just now it's calling dash home and dash home it will call service and then service will call async end point in this case home is the root and the service is actually waiting the home is waiting for service to finish but service will call async but async it doesn't wait until async finish so in this case it's a hierarchy of home is the parent of service service is parent of async but async the service doesn't need to wait until async finish so this but now this is only one application you can imagine if it's in a distributed system this can be very useful for you yep so that will be the open tracing which is quite easy set up as well you just need it has support for many languages let me open the it has support for at least all the languages I have mentioned just now Go, JavaScript, Java, Python Object C and C++ so this will be a good use case for you if you are building a micro service application so that will be the end of my talk any questions at least we beat the boss right ya, sure so how does open tracing is compared to Open ZMP or other distributed tracing sure the question is how is Open Tracing compared to other the other framework I have mentioned now if you notice here actually Open Tracing is using ZMP which is the other one I mentioned from Twitter because ZMP is actually you can see as a database or backend of the whole part the Open Tracing is a whole framework which contains of this and together with just now the UI which is called AppDash ya and plus the SDK or libraries you will use in your application ya any other questions or anyone want to right another language ya, sure so in your opinion which language is the easiest to do logging interesting that will be a tough question I'm like just now I have shared for single assistant because I'm coming from the Java and the XML logging is quite I will say quite standard and quite useful because you don't need to change code that is one of the best things you want to do so I will say maybe Java logging and it has a lot of options for you to choose from as well ya so if there is normal question I think that's the end of the day there are some links I will share the links and my code on the GitHub as well little after the so this this will be the GitHub link so I've only today there is only one speaker and that's the end so we are still looking for speakers but given the situation we might want to consider host the meet up as like two months every two months rather than every month until we get enough speakers so that ya so if you want to speak please send me an email or send me a meet up message and again thanks for DBS for providing food and venue for us ya so that's all ya thank you